-
Notifications
You must be signed in to change notification settings - Fork 9k
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
api_key in header doesn't work at all #1593
Comments
+1 |
I've spent far too long looking at this. The problem is that the method used in the docs (window.swaggerUi.api.clientAuthorizations.add) will only add the header if it is present in the "security" element of the operation, within the api-docs. In the pet store example (http://petstore.swagger.io/v2/swagger.json), GET /pet/{petId} will allow the api_key parameter, but POST to the same endpoint will only apply the OAUTH security (petstore_auth). This also seems to mean that there is no mechanism to arbitrarily set header values, which the documentation leads us to believe. |
Hi, by design, you must specify where the header needs to be applied. For example, if you want to secure every operation, you should add the If you want to add arbitrary headers, you are correct--the security scheme supports adding named headers as defined in the If you want to add arbitrary headers, please use the appropriate mechanism, which is done via creating a custom request signing mechanism (see https://github.com/swagger-api/swagger-js#custom-request-signing). These tools should give you what you're looking for. If they're hard to find, hard to understand, or don't behave the way you'd expect, please open a bug. |
+1, I ran into the same problem. What I understood from the docs, my definition (see below, "securityDefinitions": {
"mykey": {
"type": "apiKey",
"name": "mykey",
"in": "header"
}
},
"security": [
{
"mykey": []
}
] |
I have solve the problem for me, and just create a pull request with my modifications. |
Maybe it could be just added drop-down for selecting the place where to put api_key, into "header", or as a "query param". It is weird it only supports api_key as a query parameter (hardcoded) since it is a bad practice in general. |
Swagger-ui uses hard-coded `api_key` query-param for api-keys, with this commit, one can override this in the swagger spec - both key-name & in (header, query etc.) There are lot's of open issues related to this, without any resolution time-table. See: swagger-api/swagger-ui#1766 swagger-api/swagger-ui#1731 swagger-api/swagger-ui#1593
Please re-test with master, #2014 should address this. |
Pretty much what the title says. It shows in the sample curl command, but if you look at the request headers, it isn't there.
The text was updated successfully, but these errors were encountered: