postmanlabs / newman

Newman is a command-line collection runner for Postman
https://www.postman.com
Apache License 2.0
6.86k stars 1.16k forks source link

Automatic Token Refresh Not Working in Newman CLI When OAuth 2.0 Access Token Expires #3219

Open maulikcoderoom opened 5 months ago

maulikcoderoom commented 5 months ago

Running postman collection with Newman CLI , I noticed that after my OAuth2.0 access token timed out, refresh token was not automatically fetching for requests within the collection. Despite having set auto-refresh token and share token enabled, and exporting the collection to run with Newman. Each request inside collection was set to inherit auth from parent

What I'm seeking is to have each API request within the collection automatically fetch a new access token when the current one expires, while running the collection through Newman without manual intervention. Is there a way to enable share token for each auto-refreshed token so I can run collection with Newman CLI ?

  1. Newman Version : 6.1.2
  2. OS details (type, version, and architecture): Windows 11 64 bit
  3. Are you using Newman as a library, or via the CLI? : Newman CLI
  4. Did you encounter this recently, or has this bug always been there: Always there
  5. Expected behaviour:
  6. Command / script used to run Newman: newman run collection-name -e collection-env
  7. Sample collection, and auxiliary files (minus the sensitive details):
  8. Screenshots (if applicable):

    Steps to reproduce the problem: Step 1: Set Auth type OAuth 2.0 for collection image

Step 2 : Enable Auto-refresh token and Share token for collection image

Step 3: Add required token information under Configure new token section for collection

Step 4: Add refresh Request - Request URL for collection image

Step 5: Set Authorization "Inherit auth from parent" for each request inside collection image

Step 6: Export collection and environment and run with Newman CLI

davidschwab commented 5 months ago

I'm also seeing the same issue. The Auto-refresh Token functionality works from the Postman desktop app, but when exporting and running from Newman, an expired token does not automatically refresh. This is a blocker for automation.

Slydew commented 1 week ago

Dear,

I have the same requirement.

on https://learning.postman.com/docs/sending-requests/authorization/oauth-20/ we need to change : " You can use auto-refresh when manually sending the request. Auto-refresh isn't supported for scheduled runs, monitors, the Postman CLI, or Newman."

Regards