Search code examples
apirestpostmanimgur

Exporting AUth2.0 bearer token with postman collection file does NOT work when executed using newman on cmd


Below are the steps

  1. Add bearer token env variable, as shown below enter image description here

  2. Add bearer token to the header on Main collection tab, and the request as shown below enter image description here enter image description here

  3. And now manually check what happens when we run - Get comments request, use the 'inherit auth from parent' option - it shows 200 OK, and returns the comments as shown below

enter image description here

  1. Now export both env variables & collection file as shown below enter image description here enter image description here

  2. Run the files on cmd with newman as shown below enter image description here

  3. Check the result of the 'Get Comments' request enter image description here

Expected: 200 OK status Actual : 401 Unauthorized stauts

Any help will be really appreciated, thanks


Solution

  • Every Sub folder should refer to the 'inherit from parent ' in the auth method . In this case, make sure the sub folder ACCOUNT has the auth method set to 'inherit from parent'. And make sure to click the save button before exporting the collection file.