sending API key as query parameter?
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 are you trying to set a 'fixed' value for the api key?
Yes, exactly :)
This will be supported in https://github.com/swagger-api/swagger-ui/issues/2915. Closing
@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
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": [] }
],
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 .
https://stackoverflow.com/questions/49050969/setting-swagger-apikey-in-version-3-0
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!