Persisting the bearer token in Postman
Mainly writing this for myself so I can refer back to it.
I wrote this post around client credentials in Azure AD B2C.
To test it, I had to copy/paste the access_token from the client credentials call to the bearer token in the API call.
You can automate it.
So first, we call the client credentials flow.
Note the test script to save the access_token in the environment.
The text is:
var jsonData = JSON.parse(responseBody);
pm.environment.set("access_token", jsonData.access_token);
The environment looks like this:
Then, for the next request to the API:
So the access_token from step 1 is automatically added as a bearer token in step 2 and you don’t have to copy and paste it all the time.
All good!