Im trying to automate postman tests with Newman. There is an issue with authorization. The authorization bearer token changes and it is dynamic. Does anyone know how to automate this?
Postman has this nice feature of variables. You can read more about them here: https://www.getpostman.com/docs/v6/postman/environments_and_globals/variables
You can store the bearer token in a variable and update it periodically as per your requirement.

You can modify this token in the pre-request script / tests script as per your needs.
For eg:
let token = pm.globals.get('dynamic_token');
token = 'newModifiedToken90332'; // Perform some operations here..
pm.globals.set('dynamic_token', token);

You can export the collection and globals into Newman and use them.
From Newman documentation you could do the following:
$ newman run mycollection.json -e dev_environment.json
-e is for using environment variables in which you can store your bearer token Recall that you can export your collection and your environment variables as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With