Auth: Set Bearer Token at the Collection level

Number of APIs: 1

⚠ This collection needs some changes before it's ready to use!


This is a collection based on Danny Dainton's blog post on how to dynamically set a Bearer Token before each request in a collection is sent. This is one of the most frequently asked question [on the community forum] too.

Before using it, update the following collection variables:

tokenBaseURL: this should be the base URL for your auth service.

authData: if your auth service requires any specific data, add it here as a JSON object

Once this is done, you can start using the collection. It will:

  1. Run the Pre-request Script at the collection level before every request
  2. If the bearer-token is not set, or if it has expired, it will request a new one and set it as a variable
  3. All requests in the collection inherit from the collection level auth:
  1. Authenticated request GET {{tokenBaseURL}}