Bläddra i källkod

Make client secret optional, depending on grant type.

bubble
Lucian Hontau 9 år sedan
förälder
incheckning
19639aba2b
2 ändrade filer med 9 tillägg och 5 borttagningar
  1. +8
    -4
      lib/swagger-oauth.js
  2. +1
    -1
      src/main/html/index.html

+ 8
- 4
lib/swagger-oauth.js Visa fil

@@ -185,7 +185,7 @@ function initOAuth(opts) {
popupMask = (o.popupMask||$('#api-common-mask'));
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push('missing client id'));
clientSecret = (o.clientSecret||errors.push('missing client secret'));
clientSecret = (o.clientSecret||null);
realm = (o.realm||errors.push('missing realm'));

if(errors.length > 0){
@@ -208,11 +208,15 @@ function initOAuth(opts) {
window.processOAuthCode = function processOAuthCode(data) {
var params = {
'client_id': clientId,
'client_secret': clientSecret,
'code': data.code,
'grant_type': 'authorization_code',
'redirect_uri': redirect_uri
};

if (clientSecret) {
params.client_secret = clientSecret;
}

$.ajax(
{
url : window.swaggerUi.tokenUrl,
@@ -227,7 +231,7 @@ window.processOAuthCode = function processOAuthCode(data) {
onOAuthComplete("");
}
});
}
};

window.onOAuthComplete = function onOAuthComplete(token) {
if(token) {
@@ -284,4 +288,4 @@ window.onOAuthComplete = function onOAuthComplete(token) {
}
}
}
}
};

+ 1
- 1
src/main/html/index.html Visa fil

@@ -37,7 +37,7 @@
if(typeof initOAuth == "function") {
initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret",
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name"
});


Laddar…
Avbryt
Spara