Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon AWS 403 InvalidAccesskey Error when I run the Amazon S3 Sample

I'm trying to just test out AWS s3 with eclipse using Java, I'm just trying to execute the Amazon s3 sample, but it doesn't recognise my credentials, and I'm sure my credentials are legitimate, it gives me the following error:

===========================================
Getting Started with Amazon S3
===========================================

Listing buckets
Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason.

Error Message: Status Code: 403, AWS Service: Amazon S3, AWS Request ID: 057D91D336C1FASC, AWS Error Code: InvalidAccessKeyId, AWS Error Message: The AWS Access Key Id you provided does not exist in our records.

HTTP Status Code: 403
AWS Error Code: InvalidAccessKeyId
Error Type: Client
Request ID: 057D91D336C1FASC

like image 283
David Mendienta Avatar asked Nov 10 '22 11:11

David Mendienta


1 Answers

a little update here: so there's a credential file that aws creates in the computer system. mine case was '/Users/macbookpro/.aws/credentials'

the file in this place decides the default accessKeyId and stuff.. go ahead and update it.

So I ran into the same issue, but i think i figured it out. I was using Node.js, but i think the problem should be the same since it's how they have structured their object was the issue.

in javascript if you run this in the backend,

var aws = require('aws-sdk');
aws.config.accessKeyId= "Key bablbalab"
console.log(aws.config.accessKeyId)

you will find it prints out something different. coz the correct way of setting the accessKeyId isn't what they have provided in the official website tutorial

aws.config.accessKeyId="balbalb" 

or

aws.config.loadFromPath = ('./awsConfig.json')

or any of that. If you log the entire "aws.config", you will find the correct way is

console.log(aws.config)
console.log(aws.config.credentials.secretAccessKey)
aws.config.credentials.secretAccessKey="Key balbalab"

you see the structure of the object? there's the inconsistence

like image 109
iamwave007 Avatar answered Nov 15 '22 13:11

iamwave007