andrewrk / node-s3-client

high level amazon s3 client for node.js
MIT License
1k stars 305 forks source link

unable to upload: InvalidRequest: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256. #141

Open YAOHAO9 opened 8 years ago

YAOHAO9 commented 8 years ago

unable to upload: InvalidRequest: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.

MartinNuc commented 8 years ago

Try to specify region.

hacktvist commented 7 years ago

The error is encountered when trying to upload in Frankfurt region. The reason of can be found here :

Amazon S3 supports Signature Version 4, a protocol for authenticating inbound API requests to AWS services, in all AWS regions. At this time, AWS regions created before January 30, 2014 will continue to support the previous protocol, Signature Version 2. Any new regions after January 30, 2014 will support only Signature Version 4 and therefore all requests to those regions must be made with Signature Version 4. For more information about AWS Signature Version 2, see Signing and Authenticating REST Requests in the Amazon Simple Storage Service Developer Guide.

How can we achieve it here now, any help is much appreciated.

MoritzKn commented 5 years ago

To fix this error pass the option signatureVersion: 'v4':

const s3 = require('s3');

const client = s3.createClient({
  s3Options: {
    accessKeyId: 'xxxx',
    secretAccessKey: 'xxxxxxxx',
    region: 'eu-central-1',
    signatureVersion: 'v4',
  },
});

See: https://stackoverflow.com/a/26538266/5587737