postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.87k stars 841 forks source link

Postman-generated documentation does not show Authorization header #12401

Open omair-inam opened 1 year ago

omair-inam commented 1 year ago

Is there an existing request for this feature?

Is your feature request related to a problem?

My API uses OAuth 2.0 for authentication with each subsequent call requiring an access token specified as a Bearer tokens in the Authorization header.

Inside the Postman app, the code is generated correctly (adding the Authorization header). However, in the docs, the generated call looks very different and the Authorization header is missing entirely. I would expect that both the docs and the app generate the same code for the same call. Here’s an example of the difference in cURL:

App:

curl -X POST \
  https://api.newsletter2go.com/oauth/v2/token \
  -H 'Authorization: Basic somebase64authkey' \
  -H 'Cache-Control: no-cache' \
  -H 'Postman-Token: 7c81033b-d712-439a-bb6b-0ec551c98a09' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F grant_type=https://nl2go.com/jwt \
  -F username=some@credentials.tld \
  -F password=somepassword

Docs

curl --request POST \
  --url https://api.newsletter2go.com/oauth/v2/token \
  --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  --form grant_type=https://nl2go.com/jwt \
  --form 'username=some@credentials.tld' \
  --form 'password=somepassword'

Describe the solution you'd like

Documented end-points and example requests in Postman-generated documentation should include any authorization bearer tokens when authentication settings have been configured for the collection

Describe alternatives you've considered

An unacceptably tedious workaround is to manually add the bearer token to every single request in the Postman collection.

Additional context

Forum discussion on this topic

omair-inam commented 1 year ago

Possible duplicate: #10789