Skip to content

Instantly share code, notes, and snippets.

@ponelat
Last active July 19, 2017 20:28
Show Gist options
  • Save ponelat/05c775d06397b24811a4 to your computer and use it in GitHub Desktop.
Save ponelat/05c775d06397b24811a4 to your computer and use it in GitHub Desktop.
Swagger-UI: Custom auth function
// This can only get called from within the success handler, as we need swagger-client to be instantiated.
function addApiKeyAuthorization(){
var key = encodeURIComponent($('#input_apiKey')[0].value);
if(key && key.trim() != "") {
var someAweseomAuth = new SwaggerClient.PasswordAuthorization("yourAuthName", "some user", "some password");
window.swaggerUi.api.clientAuthorizations.add("yourAuthName", someAweseomAuth);
}
}
@rtoal
Copy link

rtoal commented Jul 19, 2017

Nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment