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

The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. The Canonical String for this request should have been #1

Open
vOtto opened this issue Jun 24, 2020 · 0 comments

Comments

@vOtto
Copy link

vOtto commented Jun 24, 2020

Hi, I'm trying to implement API Gateway IAM Authorisation. Everytime I do request I'm getting this error message.
The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. The Canonical String for this request should have been
Here's my code:

const axios = require ( 'axios')
const aws4 = require ( 'aws4-react-native');

var data = JSON.stringify({"email":"****.com","password":"******"});

const opts = {
	host: '****.execute-api.eu-west-1.amazonaws.com', 
	method: 'post',
	url: 'https://****.execute-api.eu-west-1.vpce.amazonaws.com/DCCuro/signin',
  data,
  'Content-Type': 'application/json', 
  x
}

const headers = aws4.sign(opts, 
	{ 
		accessKeyId: '******', 
		secretAccessKey: '******'
	}
)
axios(headers).then(body => {
	console.log(body)
}).catch(err => {
  console.log(err.response)
})

Here's how signed object by `aws4.sign` looks like 
{
  method: 'post',
  url: 'https://****.execute-api.eu-west-1.amazonaws.com/****/****',
  data: '{"email":"*****","password":"******"}',
  'Content-Type': 'application/json',
  headers: {
    Host: '*****.execute-api.eu-west-1.amazonaws.com',
    'X-Amz-Date': '20200624T104207Z',
    Authorization: 'AWS4-HMAC-SHA256 Credential=***Creds**/20200624/eu-west-1/execute-api/aws4_request, SignedHeaders=host;x-amz-date, Signature=****Sig****'
  },
  path: '/'
}

Here's the message from error
```message: 'The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for detail'  
'The Canonical String for this request should have be' 
"'PO" 
'/****/**'  
'host:*****.execute-api.eu-west-1.amazonaws.c' 
'x-amz-date:20200624T10420'  
'host;x-amz-da' 
"****HASH1***"  
'The String-to-Sign should have be' 
"'AWS4-HMAC-SHA2" 
'20200624T10420' 
'20200624/eu-west-1/execute-api/aws4_reque' 
"***Different hash***"```

Can you advice what's wrong ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant