# Postman CLI doesn't use authentication

**URL:** <https://community.postman.com/t/postman-cli-doesnt-use-authentication/48314>\
**Category:** Help Hub\
**Tags:** postmancli\
**Created:** [June 8, 2023, 12:01pm UTC](https://community.postman.com/t/postman-cli-doesnt-use-authentication/48314 "2023-06-08T12:01:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noceo](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/noceo/32/16040_2.png) [@Noceo](https://community.postman.com/u/Noceo)\
**Post date:** [June 8, 2023, 12:01pm UTC](https://community.postman.com/t/postman-cli-doesnt-use-authentication/48314/1 "2023-06-08T12:01:38Z")

</div>

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:

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

```

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

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [June 10, 2023, 4:54pm UTC](https://community.postman.com/t/postman-cli-doesnt-use-authentication/48314/2 "2023-06-10T16:54:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Noceo](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/noceo/32/16040_2.png) [@Noceo](https://community.postman.com/u/Noceo)\
**Post date:** [June 13, 2023, 6:56am UTC](https://community.postman.com/t/postman-cli-doesnt-use-authentication/48314/3 "2023-06-13T06:56:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![altimetry-pilot-5843](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@altimetry-pilot-5843](https://community.postman.com/u/altimetry-pilot-5843)\
**Post date:** [December 4, 2023, 9:45am UTC](https://community.postman.com/t/postman-cli-doesnt-use-authentication/48314/4 "2023-12-04T09:45:42Z")

</div>

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?
