Using oauth2 tokens in CLI runner

I’m using the Oauth2 Helper Tool to generate a token manually at the folder level, and I’ve set the requests in the folder to inherit the auth from the parent. Those requests do say “This request is using OAuth 2.0 from folder ”. And when those requests are run individually through the UI they work fine.

However, running the entire folder using the Postman CLI, those requests all return 401s. I’ve deleted and generated tokens immediately before using the CLI, but nothing can get them to work.

This seems like pretty basic functionality that I can’t even find any valid documentation for - Postman has docs for obtaining a token via the UI (which I already can do) but no docs for obtaining or using a token via the CLI.

Can someone please either let me know if what I’m asking is not supported, or if Postman offers a way to do this?

1 Like

Hey @dougleenhoutsvivint :wave:

The Postman CLI does not support the OAuth 2.0 helper. This would also be the same for Newman and Monitors.

There was a gap in the documentation around the usage of this with the CLI tool and we have raised a ticker to get that added.

We’re also looking into the error messaging around those responses coming from the CLI to make it more explicit.

Thanks - is there any hope of programmatically generating tokens? Even the helper tool hides all the rest calls it makes so I can’t duplicate that functionality. This means that I have to manually get a token in order to use the CLI at all, which severely hampers automation efforts.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Hi @dougleenhoutsvivint. I would love to get your opinion on how you expect this workflow to be modelled.

It’s extremely difficult to replicate the behaviour of the OAuth 2.0 helper on the CLI. This is because of the authorization grant step required. A user need to be directed to an OAuth screen where they authenticate the client and are redirected to a redirect_uri. All of these have to be manual and can’t be replicated on a CLI.

If this step is included in a CLI, it would require a manual process defeating the purpose of automation. You’re required to only authenticate once, and we auto-refresh the token for you. This token can be stored in an environment variable which is usable on the CLI.