Renewing expired access tokens in umbracoExternalLoginToken table

I am using Microsoft Azure AD to login members in our site (Umbraco 13). I need to use their access token to make a call to the Graph API on their behalf.

After some looking around, I found the tokens in umbracoExternalLoginToken table and I’m currently using the access_token to authenticate the call to the Graph API.

However, I found that the access token expires even while the user is logged in, as the cookie expiration is different from the token’s expiry. I can see there is a refresh token in the table but it does not seem to be used to renew the access token.

Is this something I need to implement manually, i.e. use the IExternalLoginWithKeyService to manually get the refresh tokens, then write some custom code to get a new access token and store it back in the table? Or is there a out of the box Umbraco/Microsoft functionality I can use?


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/113648-renewing-expired-access-tokens-in-umbracoexternallogintoken-table