Add redirect_uri to access token request in keycloak.js
This commit is contained in:
parent
b16845a09e
commit
c3c6d4cbba
1 changed files with 8 additions and 2 deletions
|
@ -120,7 +120,7 @@
|
|||
redirectUri += (redirectUri.indexOf('?') == -1 ? '?' : '&') + 'prompt=' + options.prompt;
|
||||
}
|
||||
|
||||
sessionStorage.oauthState = state;
|
||||
sessionStorage.oauthState = JSON.stringify({ state: state, redirectUri: encodeURIComponent(redirectUri) });
|
||||
|
||||
var url = getRealmUrl()
|
||||
+ '/tokens/login'
|
||||
|
@ -315,6 +315,8 @@
|
|||
params += '&client_id=' + encodeURIComponent(kc.clientId);
|
||||
}
|
||||
|
||||
params += '&redirect_uri=' + oauth.redirectUri;
|
||||
|
||||
req.withCredentials = true;
|
||||
|
||||
req.onreadystatechange = function() {
|
||||
|
@ -538,9 +540,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ((oauth.code || oauth.error) && oauth.state && oauth.state == sessionStorage.oauthState) {
|
||||
var sessionState = sessionStorage.oauthState && JSON.parse(sessionStorage.oauthState);
|
||||
|
||||
if (sessionState && (oauth.code || oauth.error) && oauth.state && oauth.state == sessionState.state) {
|
||||
delete sessionStorage.oauthState;
|
||||
|
||||
oauth.redirectUri = sessionState.redirectUri;
|
||||
|
||||
if (oauth.fragment) {
|
||||
oauth.newUrl += '#' + oauth.fragment;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue