Last active
November 1, 2023 22:44
-
-
Save smereczynski/5a558a82ba4430b15f6fc8d478edbf2c to your computer and use it in GitHub Desktop.
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 client_id = pm.environment.get("client_id"); | |
var client_secret = pm.environment.get("client_secret"); | |
var tenant = pm.environment.get("tenant") | |
pm.sendRequest({ | |
url: 'https://login.microsoftonline.com/' + tenant + '/oauth2/token', | |
method: 'POST', | |
header: { | |
'Content-Type': 'multipart/form-data', | |
}, | |
body: { | |
mode: 'formdata', | |
formdata: [ | |
{key: "client_id", value: client_id}, | |
{key: "client_secret", value: client_sercret}, | |
{key: "resource", value: "https://management.azure.com/"}, | |
{key: "grant_type", value: "client_credentials"}, | |
] | |
} | |
}, function(err, response) { | |
const jsonResponse = response.json(); | |
pm.environment.set("access_token", jsonResponse.access_token); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment