'Postman: Get bearer token from collection authorization in pre-request script
In postman I have a collection, where each request uses collection-level Bearer Token authorization.
Now, what I would like to do is to send http request in my pre-request script (For refreshing access token), but I don't know is it possible to get access token (from collection Authorization) in pre-request scripts. I know I can get collection variables like
pm.collectionVariables.get("key),
but is there also a way to get (and also set) value from Authorization?
Solution 1:[1]
You can set the Token as a collection variable {{my_token}} and then use
pm.collectionVariables.set("my_token", "tokenvaluehere") in your pre-request script.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |


