swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

sending API key as query parameter?

Open emckean opened this issue 9 years ago • 8 comments

In swagger-ui 2.0 this works to add an api key as a query param:

authorizations: {
          api_key: new SwaggerClient.ApiKeyAuthorization("api_key", '<%=data.config.developerKey%>', "query")
        },

In swagger-ui 3.0 I think that this should be the right syntax but it does not add the api key as a query param:

ui.authActions.authorize({api_key: {name: "api_key", schema: {type: "apiKey", in: "query", name: "api_key"}, value: '<%=data.config.developerKey%>'}});

The security definition in the OAS spec is:

"securityDefinitions": {
    "api_key":{
          "type": "apiKey",
          "name": "api_key",
          "in": "query"}
  },

What am I missing? Any suggestions gratefully received.

I should add that I'm opening this as an issue b/c I think the lack of documentation is the issue. If you tell me what it should be I will write it up and fix it. :)

emckean avatar Jul 04 '17 19:07 emckean

@emckean are you trying to set a 'fixed' value for the api key?

webron avatar Jul 05 '17 18:07 webron

Yes, exactly :)

emckean avatar Jul 05 '17 19:07 emckean

This will be supported in https://github.com/swagger-api/swagger-ui/issues/2915. Closing

shockey avatar Jan 15 '18 23:01 shockey

@webron @emckean can you please let me know what is the solution here. I am also facing same issue, earlier i used to use swagger 1.2 v now i am using version 2.0 Now it is not working with same code....how should i change the code to fix it. below is what i have , what am i missing here.

"authorizations": { "api_key": { "type": "apiKey", "passAs": "qwerty", "in": "query", "name": "api_key" } },

https://stackoverflow.com/questions/49050969/setting-swagger-apikey-in-version-2-0

shatestest avatar Mar 01 '18 17:03 shatestest

Sorry, I reverted to 2.0 :)

Do you have something that looks like this?

"securityDefinitions": {
    "api_key":{
          "type": "apiKey",
          "name": "api_key",
          "in": "query"}
  },
  "security": [
      { "apiKey": [] }
    ],

emckean avatar Mar 01 '18 20:03 emckean

yes. but no use. like the below

"components": { "securitySchemes": { "ApiKeyAuth": { "type": "apiKey", "in": "query", "name": "apiKey" } } }, "security": [ { "ApiKeyAuth": [ 'qwerty' ] } ],

On Fri, Mar 2, 2018 at 1:30 AM, Erin McKean [email protected] wrote:

Sorry, I reverted to 2.0 :)

Do you have something that looks like this?

"securityDefinitions": { "api_key":{ "type": "apiKey", "name": "api_key", "in": "query"} }, "security": [ { "apiKey": [] } ],

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/swagger-api/swagger-ui/issues/3337#issuecomment-369712713, or mute the thread https://github.com/notifications/unsubscribe-auth/AF_pYShEeQ08uE_x6jVknisGND4MY4B8ks5taFNngaJpZM4ONoiO .

shatestest avatar Mar 05 '18 15:03 shatestest

https://stackoverflow.com/questions/49050969/setting-swagger-apikey-in-version-3-0

shatestest avatar Mar 05 '18 15:03 shatestest

Locking due to inactivity.

This is done to avoid resurrecting old issues and bumping long threads with new, possibly unrelated content.

If you think you're experiencing something similar to what you've found here: please open a new issue, follow the template, and reference this issue in your report.

Thanks!

lock[bot] avatar Jul 02 '19 11:07 lock[bot]