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

Refresh token problem. Token expiring after 1 hour. #764

Closed viganella closed 4 years ago

viganella commented 6 years ago

Hi When reading adal documentation I saw that when user authenticates to AAD they have an access_token and a refresh token (that can renew acccess_token for up to 90 days). I have an application that uses websocket connection to get data from cloud and after 1 hour letting it run I get 'access_token_expired ' message. My question is that, is there anything special i have to do to let user stay logged-in for a longer period of time e.g. for days ? Or is this another bug?

viganella commented 6 years ago

After 1 hour I get the error message ('user login is required'). I have 'keep my signed in option enabled'. My localstorage: token_expired_localhoststorage

viganella commented 6 years ago

I have investigated further here and what seems to have caused that is because on refresh I was loosing (this_user <-null), so that after 1 hour Adal was requesting for a fresh log-in. This is not ok of course, since I should not loose user after he refreshes, it is just very unreliable.

viganella commented 6 years ago

Following up I actually am calling this.get('session')._context.getCachedUser(); ON page REFRESH which will actually set again the user from idtoken.

mchint01 commented 6 years ago

We are having same error, what is the resolution for this? We are calling getCachedUser() on page refresh as well. Still having the issue of token not renewing

atlefren commented 5 years ago

Can also reproduce this bug. Can confirm it is related to this._user beeing null after a page reload. Will submit a PR with fix asap

sameerag commented 4 years ago

Please check documentation on token renewal here. All tokens expire after an hour, but calling acquireTokenSilent() in the background before the token expiry renews the token.

All current authentication work from microsoft is delivered through msal js library here. adal js is still supported only for security fixes. We would recommend to move to msal js for any advanced feature asks.

atlefren commented 4 years ago

So, after 1.5 years this issue is closed with a link to how to do the asked thing in msal. Thus: for all intents and purposes adal.js is deprecated?

Could you please state this clearly in the readme?

sameerag commented 4 years ago

Yes, we will soon. We are trying to figure out usage issues vs feature asks and will add the documentation soon.