Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acquireToken does not make callback when token is expired #111

Open
mikerains opened this issue Dec 20, 2018 · 1 comment
Open

acquireToken does not make callback when token is expired #111

mikerains opened this issue Dec 20, 2018 · 1 comment

Comments

@mikerains
Copy link

in adal.js:

  • acquireToken.js does not have a call to this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW, expectedState, true);
  • acquireTokenRedirect does have this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW, expectedState, true);
  • Because it is not in storage, _matchState() doesn't find it and hence doesn't set reqest.REQUEST_TYPE = "RENEW_TOKEN" and doesn't set request.stateMatch to true.
  • Because

Because request.stateMatch is not true, adal.service's handleWindowCallback() does not invoke this.context._callBackMappedToRenewStates[requestInfo.stateResponse] here:

            if (requestInfo.stateMatch) {
                if (typeof callback === 'function') {
                    if (requestInfo.requestType === this.context.REQUEST_TYPE.RENEW_TOKEN) {
                        // Idtoken or Accestoken can be renewed
                        if (requestInfo.parameters['access_token']) {
                            callback(this.context._getItem(this.context.CONSTANTS.STORAGE.ERROR_DESCRIPTION)
                                , requestInfo.parameters['access_token']);

Also, because adal's acquireToken doesn't make the callback, adal.service's refreshLoginToken

@geerzo
Copy link
Collaborator

geerzo commented Dec 21, 2018

Are you using 4.x? That version should have fixed this issue. You are correct match states fails but in the adal.js method getRequestInfo it has this fallback code which gets called.

                // external api requests may have many renewtoken requests for different resource
                if (!requestInfo.stateMatch && window.parent) {
                    requestInfo.requestType = this._requestType;
                    var statesInParentContext = this._renewStates;
                    for (var i = 0; i < statesInParentContext.length; i++) {
                        if (statesInParentContext[i] === requestInfo.stateResponse) {
                            requestInfo.stateMatch = true;
                            break;
                        }
                    }
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants