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 374 forks source link

Token is null in requests when loginInProgress() #731

Closed luis-ribeiro closed 6 years ago

luis-ribeiro commented 6 years ago

Hi, not sure if this is an error or if I am not seeing all the aspects of adal.

In some cases, my authentication or request process hits this condition, where tokenStored is null, and in the following conditions authService.loginInProgress() is true.

image

So, from what I understood, when the login process ends, it will broadcast an event, and this function will be executed, setting the new token in the config.headers.Authorization variable.

image

But, it is setting the new token using the "tokenStored" variable instead if "token", that is an input argument of the function. tokenStored is null. Token variable have the correct token.

This causes the request to be performed with an invalid authorization header value. image

Adal version is AdalJS v1.0.16, but in the 17 the code is the same.

Any suggestion?

Thanks, Luis Ribeiro

rohitnarula7176 commented 6 years ago

@luis-ribeiro Thank you for pointing out this issue. I have made a fix for it in the dev branch. The way this was previously working is when you say deferred.resolve(config) in the interceptor, it re sends the http request and then the variable tokenStored gets assigned as it is saved in the browser cache when the method is broadcasted.

Closing this issue for now. Please reopen if you face any more issues. I will add this fix as part of our next release.