Postman CLI doesn't use authentication

I have made a collection, to which I’ve added a handful of tests. I have set up authorization (OAuth 2.0) on the collection itself and enabled “Auto-refresh token”.

When I run the collection with the Runner in the Postman UI, everything works fine. But when I run it from the Postman CLI, everything return 401 status codes.

I am running it with the following command in Power Shell:

postman collection run (...) -e (...) --insecure

Do I need to do anything (besides postman login) to get it to use the built in authorization?

It sounds like an issue with your variables. When you use the Postman CLI to fetch a collection, you only have access to the Initial value of your collection variables.

If you use environments, you also need to specify them in your Postman CLI collection run command.

I’m not updating any collection variables during the run. The authentication does use a value from the environment, but that is the initial value.

Do you know if the authentication on a collection is run automatically when you run it from the CLI, or if you need to run it manually somehow?

Good question because I’m stuck here too. If oauth2.0 set in Postman’s native way, is there a chance that Postman will get the auth token itself on Posman CLI collection run?