Skip to content

Commit 8a2072d

Browse files
committed
Merge pull request swagger-api#1648 from estiller/master
Support additional query parameters during OAuth2 authorization process
2 parents 0cc6203 + 6f006cb commit 8a2072d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
clientSecret: "your-client-secret-if-required",
5252
realm: "your-realms",
5353
appName: "your-app-name",
54-
scopeSeparator: ","
54+
scopeSeparator: ",",
55+
additionalQueryStringParams: {}
5556
});
5657
}
5758

lib/swagger-oauth.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var oauth2KeyName;
77
var redirect_uri;
88
var clientSecret;
99
var scopeSeparator;
10+
var additionalQueryStringParams;
1011

1112
function handleLogin() {
1213
var scopes = [];
@@ -156,6 +157,9 @@ function handleLogin() {
156157
url += '&client_id=' + encodeURIComponent(clientId);
157158
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator));
158159
url += '&state=' + encodeURIComponent(state);
160+
for (var key in additionalQueryStringParams) {
161+
url += '&' + key + '=' + encodeURIComponent(additionalQueryStringParams[key]);
162+
}
159163

160164
window.open(url);
161165
});
@@ -190,6 +194,7 @@ function initOAuth(opts) {
190194
clientSecret = (o.clientSecret||null);
191195
realm = (o.realm||errors.push('missing realm'));
192196
scopeSeparator = (o.scopeSeparator||' ');
197+
additionalQueryStringParams = (o.additionalQueryStringParams||{});
193198

194199
if(errors.length > 0){
195200
log('auth unable initialize oauth: ' + errors);

0 commit comments

Comments
 (0)