0
votes

I am looking for an easy way to add bearer tokens to PostMan. I have imported my API into PostMan from a swagger definition, and am wondering if authorization can be added automatically to all requests in some easy way, such that I do not have to change the Authorization header for each endpoint whenever the token changes.

I am currently requesting a token at /token for my API by sending an x-www-form-urlencoded request containing the parameters username, password and grant_type with a password value.

The returned access_token is then appended to the Authorization header in the format "Bearer token-received-from-token-endpoint" for each request to the API.

The backend is implemented with AspNet Identity Framework and AspNet Web API 2.

1
best answer using Environments and Variables here stackoverflow.com/questions/49785592/bearer-token-in-postmanBlack

1 Answers

1
votes

Good approach here is chaining request

When you get a token, assign it to an environment variable and use that variable in your subsequent requests. This way you will have a fresh token every time and your other requests can use that on runtime