Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configured for Amazon S3 storageService.getContainer() returns error #1052

Closed
aantipov opened this issue Jan 27, 2015 · 8 comments
Closed

Configured for Amazon S3 storageService.getContainer() returns error #1052

aantipov opened this issue Jan 27, 2015 · 8 comments
Labels

Comments

@aantipov
Copy link

Hey there!
I want to implement a remote method for uploading images to Amazon S3.
According to the article http://docs.strongloop.com/display/public/LB/Storage+service I defined amazon's credentials in /server/datasources.json.
Then in my model's code I am trying to implement a remote method:

Hike.uploadImage = uploadImage;
Hike.remoteMethod(
  'uploadImage',
  {
    description: 'Upload hike\'s image',
    http: {verb: 'post'},
    returns: {arg: 'data', type: 'Object', root: true}
  }
);

function uploadImage(next) {
  var s3 = Hike.app.datasources.s3.createModel('HikeFile');
  s3.getContainers(function (err, data) {
    err && next (err, {});
    next(null, data);
  });
}

At this stage this method only returns S3 buckets info & it works fine.
But if I replace s3.getContainers() call by s3.getContainer('myBucket`, fn), then this method return Error:

{
  "error": {
    "name": "InvalidRequest",
    "status": 400,
    "message": "The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.",
    "code": "InvalidRequest",
    "time": "2015-01-27T07:59:28.751Z",
    "statusCode": 400,
    "retryable": false,
    "retryDelay": 30,
    "stack": "InvalidRequest: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.\n    at Request.extractError ..."
  }
}

I've made some research & found out that this error is caused by my bucket region requirement to use AWS Signature Version 4 for authentication.
If I use aws-sdk for Node.js to make requests to Amazon S3 API then I need to specify signatureVersion parameter: var s3 = new AWS.S3({signatureVersion: 'v4', region: 'eu-central-1'});.

How can I circumvent the problem in LoopBack?

@kussberg
Copy link

kussberg commented Jul 2, 2015

+1 i have the same error right now and can't do anything in the S3

@philippdhh
Copy link

Any news on this topic?

I've got the same problem and just opened a related issue here: strongloop/loopback-component-storage#101

I hope this fix should be quite simple for a loopback guru, but unfortunately I don't know where and how to fix it yet. It really seems to be related with the signature version which should be set to v4...

This problem only occurs when using region Frankfurt and other new created aws regions. In old us and ireland regions the problem does not occur.

@ataraxus
Copy link

ataraxus commented Dec 4, 2015

Same issue here, Frankfurt region: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256

@kgoedecke
Copy link

+1 from me for the frankfurt region.

@ataraxus
Copy link

ataraxus commented Jan 7, 2016

@kgoedecke I've resolved it for myself, just try this:

See here whats was the issue: aws/aws-sdk-js#829
for Frankfurt you have just to set the "correct" region:

var publicHandler = new StorageService(
{
provider: 'amazon',
region: "eu-central-1",
keyId: "",
key: ""
});

strongloop/loopback-component-storage#101 (comment)

@gunjpan
Copy link
Contributor

gunjpan commented Aug 16, 2016

@aantipov : Looks like @ataraxus solution may have resolved the issue. Closing this for now. If you the case still persists for you, please shout out at myself in a comment and I'll reopen it. Thank you.

@gunjpan gunjpan closed this as completed Aug 16, 2016
@jdforsythe
Copy link

@gunjpan This isn't really solved. It's only solved if your region doesn't require V4 and you set your region. Regions like us-east-2 only support V4 and so this is still an issue for me

@gunjpan
Copy link
Contributor

gunjpan commented Mar 28, 2017

@jdforsythe : Hi, could you please open a new issue with detailed description of the problem you face, along with a reference to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants