From bfc33ec6cdc3e9ffad064bfda4c466c80bc6dd7d Mon Sep 17 00:00:00 2001 From: Tom Demeranville Date: Fri, 18 Dec 2015 16:11:25 +0000 Subject: [PATCH] Added support for client credentials (application) flow Added support for multiple authentication schemes To use the client credentials, index.html needs to have 1. input boxes to receive client id and client secret 2. handlers that intitialise OAuth correctly on change. For example, you could replace the explore and apikey inputs in the header with:
and add the following javascript to handle updates within the initialisation block (replacing the apikey javascript): function updateOauth(){ initOAuth({ clientId: $('#input_clientId')[0].value, clientSecret: $('#input_clientSecret')[0].value, realm: "blank", appName: "blank" }); } $('#input_clientId').change(updateOauth); $('#input_clientSecret').change(updateOauth); These examples could be incorporated into the swagger index.html file if required (or a new example created) Issues - displaying multiple schemes could be improved. Currently the UI is unaware that a particular scheme is required for a call so displays all scopes as options. Will require work on core swagger ui and templates to make scheme available to swagger-oauth.js --- lib/swagger-oauth.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/swagger-oauth.js b/lib/swagger-oauth.js index f782281b..171ea60b 100644 --- a/lib/swagger-oauth.js +++ b/lib/swagger-oauth.js @@ -18,7 +18,6 @@ function handleLogin() { for(key in defs) { var auth = defs[key]; if(auth.type === 'oauth2' && auth.scopes) { - //oauth2KeyName = key; var scope; if(Array.isArray(auth.scopes)) { // 1.2 support