My current project is Oauth 2.0 autho based.At postman,I can generate accesstoken using #Getnewaccesstoken button for my collection.
I dont want to click the generate token button in every time...Is any option there in prerequiste script form for automating this step...
Yes, you can use an access token
to assign variable
.
This is demo, current you use "Get New Access Token" I am using Keycloak v.18, getting token as admin
You can make own POST call for getting access-token
and then assign same name variable.
Before your API call, you needs this code in Tests
section.
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("access-token", jsonData.access_token);
POST call, your token URL and key/value for your inputs.
If you success, will get response in body
In the Authorization
tab, select Bearer Token
Type
And Add this code. it is access token.
{{access-token}}