Created
September 20, 2021 13:46
-
-
Save antoinedelia/de38297cb14b189c97883cbe8ec50eb7 to your computer and use it in GitHub Desktop.
Postman pre-request script to get Cognito access token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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