openapi-to-postman icon indicating copy to clipboard operation
openapi-to-postman copied to clipboard

Postman is unable to import OpenApi 3 with multiple API keys

Open mastazi opened this issue 3 years ago • 19 comments

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)

mastazi avatar Feb 08 '22 02:02 mastazi

@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?

umeshp7 avatar Feb 14 '22 16:02 umeshp7

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": []
]

mastazi avatar Feb 15 '22 22:02 mastazi

@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

AlexKotsc avatar Jun 17 '22 13:06 AlexKotsc

@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.

mastazi avatar Jun 20 '22 05:06 mastazi

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

seahagcafe avatar Aug 29 '22 17:08 seahagcafe

Hello here, any news about this support ?

luigi-13 avatar Sep 23 '22 18:09 luigi-13

@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.

tuftii avatar Jan 23 '23 14:01 tuftii

@tuftii FYI Insomnia version 2022.6.0 or newer supports it.

mastazi avatar Jan 24 '23 06:01 mastazi

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

akshaydeo avatar Feb 07 '23 08:02 akshaydeo

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

Amazing! Thank you so much.

tuftii avatar Feb 07 '23 09:02 tuftii

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

md250721 avatar Mar 07 '23 21:03 md250721

@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 🙇‍♂️

akshaydeo avatar Mar 13 '23 04:03 akshaydeo

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

jjcollinge avatar May 11 '23 14:05 jjcollinge

@akshaydeo Do you have any update? Thank you!

bornart avatar May 22 '23 10:05 bornart

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

kegs85 avatar Aug 19 '23 10:08 kegs85

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 🙇‍♂️

akshaydeo avatar Aug 28 '23 06:08 akshaydeo