AzureAD / azure-activedirectory-library-for-js

The code for ADAL.js and ADAL Angular has been moved to the MSAL.js repo. Please open any issues or PRs at the link below.
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/maintenance/adal-angular
Apache License 2.0
627 stars 372 forks source link

renewToken response with handleWindowCallback calls callback with null token unless acquireToken has been called #754

Closed RobPethick closed 6 years ago

RobPethick commented 6 years ago

I am calling renewToken to get my access_token and then using handleWindowCallback to

From line 1340

                if (window.parent !== window) {
                    self.verbose("Window is in iframe, acquiring token silently");
                } else {
                    self.verbose("acquiring token interactive in progress");
                }

                token = requestInfo.parameters[self.CONSTANTS.ACCESS_TOKEN] || requestInfo.parameters[self.CONSTANTS.ID_TOKEN];
                tokenType = self.CONSTANTS.ACCESS_TOKEN;
            } else if (requestInfo.requestType === this.REQUEST_TYPE.LOGIN) {
                token = requestInfo.parameters[self.CONSTANTS.ID_TOKEN];
                tokenType = self.CONSTANTS.ID_TOKEN;
            }

The issue is that we need requestInfo.requestType to be RENEW_TOKEN but it isn't set to RENEW_TOKEN in the _renewToken method (it does set it in the acquireToken method).

I think we just need to set the requestType in the renewToken

rohitnarula7176 commented 6 years ago

@RobPethick You should not call renewToken directly as it is a private method. You should call acquireToken which internally calls renewToken. Can you explain the need to call the private api directly.

RobPethick commented 6 years ago

nope - I was unaware this was the wrong method - I have switched to acquireToken and it works fine I couldn't find docs to explain what the public methods were - am I missing them somewhere?

nehaagrawal commented 6 years ago

@RobPethick - Sorry that our docs are not very clear. We are working towards updating it. We will do our best to avoid such confusions in future.

RobPethick commented 6 years ago

NP - it is working great for me now