Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postman is unable to import OpenApi 3 with multiple API keys #465

Open
mastazi opened this issue Feb 8, 2022 · 16 comments
Open

Postman is unable to import OpenApi 3 with multiple API keys #465

mastazi opened this issue Feb 8, 2022 · 16 comments
Labels
auth Issue relates to Authorization of generated collection/request. importer

Comments

@mastazi
Copy link

mastazi commented Feb 8, 2022

We have an OpenApi 3 collection with multiple API keys, as described at the following link under the paragraph "multiple API keys": https://swagger.io/docs/specification/authentication/api-keys/

When importing this, it is expected that the various endpoints will have both headers (in our case, x-api-key and x-api-secret).

Feeding the same OpenApi file to ReDoc, both authentication headers are correctly recognised:
Screen Shot 2022-02-08 at 8 47 15 am

However, when importing into Postman, only x-api-key is present in the imported collection, while the header x-api-secret has to be created manually.
Screen Shot 2022-02-08 at 1 02 38 pm

So it seems that the feature "Multiple API Keys" that is part of the OpenAPI 3 spec, is not implemented yet in Postman https://swagger.io/docs/specification/authentication/api-keys/

Using Postman Version 9.12.2 (9.12.2) for MacOS Arm64
On Mac OS Monterey
On MacBook Air M1

(my colleagues reproduced the same issue on Monterey on Mac Intel, on Win 10 and on Win 11)

@umeshp7
Copy link
Member

umeshp7 commented Feb 14, 2022

@mastazi Thank you for reaching out.

This is a known limitation and we are aware the behavior. The issue with having multiple API Key is that Postman Collection doesn't support having multiple authorization for a Request or even for the entire collection.

If things are added on the global level those are added to the collection level auth and if it is present at the path level it is added to the request. But if there are multiple we pick the first one only.

One possible workaround we could do is add the other API key in your case as a separate header but that will be a temporary fix. Would love to hear your thoughts around this and if you have any suggestions on how this can be handled?

@VShingala VShingala added the auth Issue relates to Authorization of generated collection/request. label Feb 15, 2022
@mastazi
Copy link
Author

mastazi commented Feb 15, 2022

Postman Collection doesn't support having multiple authorization

Hi @umeshp7 thank you for your response. My initial instinct (and I say that as someone who is not familiar with this codebase) is that the problem could be resolved by parsing security rather than components.securitySchemes, the reason I say that, is that according to the OpenAPI 3 specs, when we want to use multiple API keys, all keys must be under the same array element. So they are grouped into one single element not multiple ones.

The docs at https://swagger.io/docs/specification/authentication/api-keys/ even make the difference clear by saying that this is the correct form:

security:
  - apiKey: []
    appId:  []   # <-- no leading dash (-)

while this is incorrect:

security:
  - apiKey: []
  - appId:  []

or in case you prefer JSON, this is correct (note how the array has one element only):

"security": [
  {
    "apiKey": [],
    "appId": []
  }
]

and this is incorrect (note that the array has two elements in this incorrect version)

"security": [
  "apiKey": [],
  "appId": []
]

@AlexKotsc
Copy link

AlexKotsc commented Jun 17, 2022

@mastazi

security:
  - apiKey: []
  - appId: []

Is not incorrect, it just means you as a client can choose which one you want to use.
https://swagger.io/docs/specification/authentication/#multiple

@mastazi
Copy link
Author

mastazi commented Jun 20, 2022

@AlexKotsc yeah, I meant incorrect from the point of view of achieving an AND as opposed to an OR.

The example you made is an OR but in our case we need an AND. Thank you for clarifying.

@seahagcafe
Copy link

@umeshp7 is there any timeline on support for multiple API keys?

@luigi-13
Copy link

Hello here, any news about this support ?

@tuftii
Copy link

tuftii commented Jan 23, 2023

@umeshp7 Is there any further update on support for multiple AND keys in Postman?

It's critical for a project I'm currently working on, and will have to look into different tooling if this is the case. Thanks.

@mastazi
Copy link
Author

mastazi commented Jan 24, 2023

@tuftii FYI Insomnia version 2022.6.0 or newer supports it.

@akshaydeo
Copy link

We are looking to ship this improvement by the end of Feb 2023. I will keep this ticket updated 🙇‍♂

@tuftii
Copy link

tuftii commented Feb 7, 2023

We are looking to ship this improvement by the end of Feb 2023. I will keep this ticket updated 🙇‍♂

Amazing! Thank you so much.

@md250721
Copy link

md250721 commented Mar 7, 2023

@akshaydeo - do you have an update on when this will be released? Thanks

@akshaydeo
Copy link

@md250721 we are still working on this change. The tentative timeline for this fix to land is April 2023 end. I will keep this thread update 🙇‍♂️

@jjcollinge
Copy link

@akshaydeo any update on the release of this? Thanks!

@bornart
Copy link

bornart commented May 22, 2023

@akshaydeo Do you have any update? Thank you!

@kegs85
Copy link

kegs85 commented Aug 19, 2023

Hi @akshaydeo, I see this was being implemented earlier this year, are there any updates as it seems to still be an issue

@akshaydeo
Copy link

Hi all, with a few high-priority changes, we de-prioritised this change. We will pick it up again and plan for Nov 2023 release. I will keep this thread updated. Apologies for the delay 🙇‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issue relates to Authorization of generated collection/request. importer
Projects
None yet
Development

No branches or pull requests