jensoleg / swagger-ui

Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
http://swagger.io
Other
1.14k stars 310 forks source link

Can't get apiKey auth to work #30

Closed richardthornton closed 8 years ago

richardthornton commented 8 years ago

Hi! First up, this is a stunning project. Thank you!

I'm having trouble getting apiKey authentication to work and while I'm sifting through the entire swagger-ui.js file trying to find a solution, thought I should post here in case you know of any limitations/requirements.

All of my calls require an api key and using the stock Swagger UI, the header api_key field works beautifully. Adding my key in this fork (and clicking the arrow) doesn't add the key to any requests. The modal shows the correct Request URL without the api key appended.

Have you seen this before?

richardthornton commented 8 years ago

Wow. I sifted through swagger-ui.js for a couple of hours before noticing the following line in index.html:

var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("Authorization", "Bearer " + key, "header");

Changing it to the following has made everything work nicely for me:

var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query");