Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jongio/28541ab8a12fb64dea25a4fd9fb46c2b to your computer and use it in GitHub Desktop.
Save jongio/28541ab8a12fb64dea25a4fd9fb46c2b to your computer and use it in GitHub Desktop.
pm.sendRequest({
url: 'https://login.microsoftonline.com/' + pm.environment.get("tenantId") + '/oauth2/token',
method: 'POST',
header: 'Content-Type: application/x-www-form-urlencoded',
body: {
mode: 'urlencoded',
urlencoded: [
{key: "grant_type", value: "client_credentials", disabled: false},
{key: "client_id", value: pm.environment.get("clientId"), disabled: false},
{key: "client_secret", value: pm.environment.get("clientSecret"), disabled: false},
{key: "resource", value: pm.environment.get("resource"), disabled: false}
]
}
}, function (err, res) {
pm.globals.set("bearerToken", res.json().access_token);
console.log(pm.globals.get("bearerToken"));
});
@sai-manoj-kumar
Copy link

Thanks a lot!

@davidjsteele
Copy link

Nice1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment