0

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.

Gryu
  • 2,102
  • 2
  • 16
  • 29
thilemann
  • 397
  • 4
  • 16
  • best answer using Environments and Variables here https://stackoverflow.com/questions/49785592/bearer-token-in-postman – Black Aug 20 '20 at 12:14

1 Answers1

1

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

Dinesh Kumar
  • 1,694
  • 15
  • 22
  • Exactly what I need. Though I wish that the token could be added automatically for all subsequent requests. – thilemann Dec 07 '15 at 08:25