Skip to content

Instantly share code, notes, and snippets.

@mvantellingen
Created May 31, 2016 08:12
Show Gist options
  • Save mvantellingen/daeb4755402d878525e57c631946d018 to your computer and use it in GitHub Desktop.
Save mvantellingen/daeb4755402d878525e57c631946d018 to your computer and use it in GitHub Desktop.
(function () {
$(function () {
var jwtUI =
'<div class="input"><input placeholder="JWT Token" id="input_jwt" name="jwt" type="text" size="20"></div>';
$(jwtUI).insertBefore('#api_selector div.input:last-child');
$("#input_apiKey").hide();
$('#input_jwt').change(addAuthorization);
});
function addAuthorization() {
var token = $('#input_jwt').val();
if (token && token.trim() != "") {
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization( "Authorization", "Bearer " + token, "header" );
window.swaggerUi.api.clientAuthorizations.add( "Bearer", apiKeyAuth );
console.log("JWT authorization added: " + token);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment