Home

Refresh token expiration

%3CLINGO-SUB%20id%3D%22lingo-sub-958832%22%20slang%3D%22en-US%22%3ERefresh%20token%20expiration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-958832%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20web%20app%20(SPA%20with%20backend)%20uses%20refresh%20tokens%20to%20access%20Microsoft%20calendars%20of%20users%20when%20they%20are%20offline.%20Today%20it%20turned%20out%20the%20refresh%20token%20I%20use%20in%20unit%20tests%20expired%20exactly%20one%20year%20after%20retrieving%20it.%20I%20searched%20the%20docs%20and%20learnt%20that%20I%20should%20ask%20for%20new%20refresh%20token%20when%20I%20use%20the%20current%20one%20to%20obtain%20access%20token%20and%20that's%20fine.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20I%20also%20figured%20out%20the%20refresh%20token%20is%20revoked%20every%20time%20user%20changes%20password%20to%20their%20Microsoft%20account.%20And%20this%20is%20the%20real%20problem%20for%20me%20because%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1)%20I%20need%20to%20access%20user's%20calendar%20when%20they%20are%20offline%20so%20when%20attempt%20to%20use%20refresh%20token%20returns%26nbsp%3B%20%22%3CSPAN%3Einvalid_grant%22%20error%20I%20can't%20ask%20user%20to%20grant%20access%20to%20their%20calendar%20again%20-%20because%20the%20user%20is%20offline.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E2)%20If%20the%20user%20changes%20their%20password%20once%20a%20month%2C%20they%20would%20have%20to%20grant%20access%20to%20their%20calendar%20in%20my%20app%20once%20a%20month%20too.%20Not%20really%20convenient%20for%20the%20user.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EAnd%20honestly%2C%20this%20policy%20doesn't%20make%20much%20sense%20to%20me.%20User%20granted%20my%20app%20access%20to%20their%20calendar%20and%20changing%20password%20has%20nothing%20to%20do%20with%20it.%20User%20can%20remove%20their%20calendar%20from%20my%20app%2C%20or%20remove%20my%20app%20from%20the%20list%20of%20authorized%20apps%20in%20their%20Microsoft%20account%20settings.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20the%20article%26nbsp%3B%3CA%20title%3D%22Configurable%20token%20lifetimes%20in%20Azure%20Active%20Directory%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpl-pl%2Fazure%2Factive-directory%2Fdevelop%2Factive-directory-configurable-token-lifetimes%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EConfigurable%20token%20lifetimes%20in%20Azure%20Active%20Directory%3C%2FA%3E%26nbsp%3Bwhich%20says%3A%3C%2FP%3E%3CH4%20id%3D%22toc-hId-1456821913%22%20id%3D%22toc-hId-1456821918%22%3E%3CEM%3E%3CSPAN%20class%3D%22sxs-lookup%22%3EToken%20lifetimes%20with%20confidential%20client%20refresh%20tokens%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FH4%3E%3CP%3E%3CEM%3E%3CSPAN%20class%3D%22sxs-lookup%22%3Ethe%20default%20lifetimes%20of%20refresh%20tokens%20issued%20to%20these%20flows%20is%20until-revoked%2C%20cannot%20be%20changed%20by%20using%20policy%2C%20and%20will%20not%20be%20revoked%20on%20voluntary%20password%20resets%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22sxs-lookup%22%3EHowever%2C%20despite%20my%20app%20is%20not%20a%20public%20app%20(%3CEM%3ETreat%20application%20as%20a%20public%20client%3C%2FEM%3E%20is%20set%20to%20%22No%22)%2C%20refresh%20tokens%20expire%20after%20one%20year%20and%20on%20password%20change.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22sxs-lookup%22%3EThe%20same%20article%20also%20says%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%3CSPAN%20class%3D%22sxs-lookup%22%3EAfter%20May%201%2C%202020%20you%20will%20not%20be%20able%20to%20use%20Configurable%20Token%20Lifetime%20policy%20to%20configure%20session%20and%20refresh%20tokens.%20%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20question%3A%20Is%20it%20possible%20to%20have%20refresh%20tokens%20that%26nbsp%3B%3CSTRONG%3Edo%20not%20expire%3C%2FSTRONG%3E%20when%20user%20changes%20password%20to%20their%20Microsoft%20account%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-958832%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOAuth%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eoauth%202%200%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eoauth2%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Etokens%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
michal_r
Occasional Visitor

Hi guys,

 

My web app (SPA with backend) uses refresh tokens to access Microsoft calendars of users when they are offline. Today it turned out the refresh token I use in unit tests expired exactly one year after retrieving it. I searched the docs and learnt that I should ask for new refresh token when I use the current one to obtain access token and that's fine.

 

However, I also figured out the refresh token is revoked every time user changes password to their Microsoft account. And this is the real problem for me because:

 

1) I need to access user's calendar when they are offline so when attempt to use refresh token returns  "invalid_grant" error I can't ask user to grant access to their calendar again - because the user is offline.

2) If the user changes their password once a month, they would have to grant access to their calendar in my app once a month too. Not really convenient for the user.

 

And honestly, this policy doesn't make much sense to me. User granted my app access to their calendar and changing password has nothing to do with it. User can remove their calendar from my app, or remove my app from the list of authorized apps in their Microsoft account settings.

 

I found the article Configurable token lifetimes in Azure Active Directory which says:

Token lifetimes with confidential client refresh tokens

the default lifetimes of refresh tokens issued to these flows is until-revoked, cannot be changed by using policy, and will not be revoked on voluntary password resets

 

However, despite my app is not a public app (Treat application as a public client is set to "No"), refresh tokens expire after one year and on password change.

 

The same article also says:

 

After May 1, 2020 you will not be able to use Configurable Token Lifetime policy to configure session and refresh tokens.

 

My question: Is it possible to have refresh tokens that do not expire when user changes password to their Microsoft account?