Custom Header Parameters - (For Basic auth etc)
If you have some header parameters which you need to send with every request, use the headers as below:
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Authorization", "XXXX", "header"));
Note! You can pass multiple header params on a single request, just use unique names for them (
key
is used in the above example).
Hooray! This is exactly what I want to do. I won't bore the faithful Google Groupers with the details, suffice to say I need to add a handful of custom headers to all of my requests. As such, I added the following two lines to addApiKeyAuthorization():
swaggerUi.api.clientAuthorizations.add("headerKey", new SwaggerClient.ApiKeyAuthorization("Some-Header", "Foo", "header"));
swaggerUi.api.clientAuthorizations.add("anotherHeaderKey", new SwaggerClient.ApiKeyAuthorization("Some-Other-Header", "Bar", "header"));
var customHeaders = {
headerKey: new SwaggerClient.ApiKeyAuthorization("Some-Header", "Foo", "header")),
anotherHeaderKey: new SwaggerClient.ApiKeyAuthorization("Some-Other-Header", "Bar", "header"))
};
swaggerUi.api.clientAuthorizations.add(customHeaders)
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
window.swaggerUi.api.clientAuthorizations.add("csrf", new SwaggerClient.ApiKeyAuthorization(header, token, 'header'));
window.swaggerUi.api.clientAuthorizations.add("auth", new SwaggerClient.ApiKeyAuthorization('X-Auth', Authcode, 'header'));
We recently added a new feature that takes the need to do manual authorization configuration.Try using the master version and just your spec in it.