node-s3-uploader
node-s3-uploader copied to clipboard
The authorization mechanism you have provided is not supported
Subject of the issue
Appear a error. InvalidRequest: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
What is that?
Your environment
- Operating system
- [ ] Mac
- [ ] Windows
- [ ] Linux
- Node.js version (
node --version
)- [ ] Node.js v4.x
- [ ] Node.js v6.x
- ImageMagick version (
identify -version
)- [ ] ImageMagick v6.9.x
- [ ] ImageMagick v7.0.x
- s3-uploader version
- [ ] v0.x
- [ ] v1.x
- [ ] v2.x
Steps to reproduce
Tell us how to reproduce this issue. Please provide a minimal code example to demonstrate the problem.
// your code here
Expected behaviour
Tell us what should happen.
Actual behaviour
Tell us what happens instead.
// log outoput or error messages here
Hi @isaacguerreir, could you fill out the rest of the template and I'll be happy to debug the problem with you 😊
Hey guys,
I had the same issue after I initialized my AWS-credentials directly with the sdk and not explicitly passing them to the s3-uploader.
The problem here is that the s3-uploader always sets the aws-region when creating the S3
-object. This is us-east-1
by default, which still supports the old aws-signature-version v2
. However, newer regions do not support it anymore. You therefore always have to explicitly set your aws-region when initializing the Upload
-object:
const client = new Upload("bucket", {
aws: {
region: "eu-central-1"
},
/**
* ...
**/
})
This solved the issue for me. Seems to me as if the aws-sdk still uses the endpoint you specified when updating your sdk-configuration although one can specify an alternative region when creating the S3
-object. Anyway I hope this helps you as well.
@isaacguerreir it's because you are using the old aws signature version v2. You can prevent this error by moving to new aws signature version v4.
when initializing your s3 client pass this signatureVersion: 'v4'
as a parameter.
let s3bucket = new AWS.S3({ accessKeyId: IAM_USER_KEY, secretAccessKey: IAM_USER_SECRET, Bucket: BUCKET_NAME, signatureVersion: 'v4' },);