What I needed
- get new oauth2.0 token from cognito endpoint.(I have clientId, secret, cognito domain, auto_by_code, redirect_url) →
token
- use this token with something like:
post below as payload tohttps://cognito-identity.ap-southeast-2.amazonaws.com/
and get respnse → res:IdentityId
,
{"IdentityPoolId":"ap-southeast-2:${MyPoolID}","Logins":{"cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_MYID":token}}
- use response to post to
https://cognito-identity.ap-southeast-2.amazonaws.com/
→session credential
{"IdentityId":"ap-southeast-2:${IdentityId}","Logins":{"cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_MYID":token}}
- 3 will get a AWS session credential , and set returned credential from 3 to environment.
Expected
Everytime I run request to test API covered by AWS sign4.0, I can get new credential that be set to AWS signature of postman authorization.
Current
My first step always get 405:“Method not allowed” error…
const postRequest = {
url: 'https://xxxxxxx.auth.ap-southeast-2.amazoncognito.com/oauth2/token',
method: 'POST',
auth: {
user: 'xxxxxxxxxxxxxxxxxx',
password: 'xxxxxxxxxxxxxxx'
},
headers:{
"Content-Type":"application/x-www-form-urlencoded"
},
form: {
grant_type: 'authorization_code'
}
}
pm.sendRequest(postRequest, (error, response) => {
console.log(response)
});