Developers should have an ability to extend the refresh_token lifetime on browser for atleast a week. Current time of 24 hours is very short
How to get >24h refresh tokens for mobile app with Azure B2C?
We are currently looking into creating a mobile app with react native (expo). The whole authentication stuff works now after a bit of tinkering. But whats a problem for us is that apparently you are not able to get refresh tokens which are valid for longer than 24h when you use the code flow with PKCE.
As far as I've gathered from online resources it's recommended to use PKCE for mobile apps for security reasons. But having the user login do a complete login after 24h is kind of a show stopper for us.
What other options are there to use refresh tokens which are valid for more than 24h in a secure way for mobile apps?
Microsoft Security | Microsoft Entra | Microsoft Entra External ID
2 answers
Sort by: Most helpful
-
-
Shweta Mathur 30,296 Reputation points Microsoft Employee Moderator
2022-08-02T08:40:57.793+00:00 Hi @Stefan Schweiger ,
Thanks for reaching out.
Your understanding is correct here. Unfortunately, as of now for Single Page Applications, the token is valid only for 24 hours. After 24 hours you need to go to /authorization endpoint of azure ad to get the new access and refresh token. This can also be also non-interactive flow if the browser has the valid login session.
Another way is to use the implicit flow where refresh token happens in hidden iframe, but implicit flow is not recommended as going further 3rd party cookies will be blocked.
The only workaround option available is to use "Keep me signed in" to get long lived sessions. In order to set the KMSI checkbox checked by default, you need to use JavaScript as there is no option available for this purpose in B2C user flow or custom policy.
Thanks,
Shweta-----------------------------
Please remember to "Accept Answer" if answer helped you.