We secure our APIs by Oauth2 Authorization code flow. By its requirements, an access token is short-lived and for every API call, we have to include a valid access token in the header of our request. Therefore for testing purposes, we need to automate the renewal mechanism of an access token to save time.
With Postman, it is possible to execute a script before or after an API call. There are 2 places where we can put these scripts: script level or collection of script level. In our case, we mainly use these scripts to manage our token and it remains the same for each call. Therefore, we regroup our API calls inside a Postman collection to prevent repeating the same script.