Hi All,
I am trying to get an OAuth 2.0 access token by authorizing using browser. However, it needs manual intervention to click “Get New Access Token.” Is there a way to automate this in the pre-requisite script? I have this snippet, but now sure how to mention “Authorize using browser” and “Get New Access Token”.
const tokenUrl = ' ';
const redirectUrl = ' ';
const clientId = ' ';
const clientSecret = ' ';
const scope = ' ';
const audience = ' '
const getTokenRequest = {
method: 'POST',
url: tokenUrl,
body: {
mode: 'formdata',
formdata: [
{ key: 'grant_type', value: 'authorization_code' },
{ key: 'redirect_uri', value: redirectUrl},
{ key: 'client_id', value: clientId },
{ key: 'client_secret', value: clientSecret },
{ key: 'scope', value: scope },
{ key: 'state', value: 'a_state' },
{ key: 'audience', value: audience }
]
}
};
pm.sendRequest(getTokenRequest, (err, response) => {
const jsonResponse = response.json();
const newAccessToken = jsonResponse.access_token;
pm.variables.set(‘access_token’, newAccessToken);
});