How to auto-refresh auth token in Postman
This is very common scenario when testing APIs in postman, we have a collection of request and those requests needs to be authenticated first. Most of the time we have to run the auth request first, grab the token from the response and then go request per request and add the token or simple create a variable in Postman and add the token, still saving the token in a variable requires to run the auth request again once the token expires.
Here is a code snippet that can help with that.
📓 Of course there is no code to rule them all, so adjust the code base on your environment variables and data used for authentication.
// Get environment variables