Postman Automatic Auth Token
Postman can run JavaScript commands when executing a request. These commands can be placed in the "Tests" tab inside a request.
For example, to automatically set a token as a collection variable, the following commands are used:
```
var auth = pm.response.headers.get("Authorization");
pm.collectionVariables.set('token', auth.split(" ")[1]);
```
The Docs regarding Postman scripting can be found here:
https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/
Mihai Barbu
24 Aug 2021
« Back to post