Skip to content

Instantly share code, notes, and snippets.

@antoinedelia
Created September 20, 2021 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoinedelia/de38297cb14b189c97883cbe8ec50eb7 to your computer and use it in GitHub Desktop.
Save antoinedelia/de38297cb14b189c97883cbe8ec50eb7 to your computer and use it in GitHub Desktop.
Postman pre-request script to get Cognito access token
pm.sendRequest({
url: "https://YOUR_COGNITO_DOMAIN_NAME_HERE.auth.eu-west-1.amazoncognito.com/oauth2/token",
method: 'POST',
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: {
mode: 'urlencoded',
urlencoded: [
{
key: "grant_type",
value: "client_credentials"
},
{
key: "client_id",
value: "YOUR_CLIENT_ID_HERE"
},
{
key: "client_secret",
value: "YOUR_CLIENT_SECRET_HERE"
},
{
key: "scope",
value: "YOUR_SCOPE_HERE"
}
]
}
}, (err, res) => {
pm.collectionVariables.set("access_token", res.json().access_token)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment