Last active
May 3, 2021 13:55
-
-
Save iuricmp/78ba4af18888364f8fa02ac32ebf3f6c to your computer and use it in GitHub Desktop.
Postman OAuth2 script - client_credentials
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
var clientId = pm.variables.get("clientId"); | |
var clientSecret = pm.variables.get("clientSecret"); | |
var scope = pm.variables.get("scope"); | |
var accessTokenURL = pm.variables.get("accessTokenURL"); | |
pm.sendRequest({ | |
url: accessTokenURL, | |
method: "POST", | |
header: [ | |
'Content-Type:application/x-www-form-urlencoded' | |
], | |
body: { | |
mode: "urlencoded", | |
urlencoded: [ | |
{key: "client_id", value: clientId}, | |
{key: "client_secret", value: clientSecret}, | |
{key: "scope", value: scope}, | |
{key: "grant_type", value: "client_credentials"} | |
] | |
}, | |
}, | |
(error, response) => { | |
pm.variables.set("rawIdToken", response.json().access_token); | |
pm.variables.set("refresh_token", response.json().refresh_token); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment