I have setup a Blazor 8 web app with Azure AD authentication using the Microsoft.Identity.Web
(AddMicrosoftIdentityWebApp from Microsoft.Identity.Web).
It all works fine as I get the access token for the web app authentication/authorization and I also use that for the Web API bearer token. The problem comes to the lack of refresh token. I have the following in the scope : offline_access, profile and openid. I don't however, get the refresh token. Due to the lack of refresh token, I am not able to refresh the access token after it expires.
I get the access token with the code below
options.Events.OnTokenValidated = async context =>
{
accessToken = context.TokenEndpointResponse!.AccessToken;
}
I was expecting the refresh token with a code like
context.GetTokenAsync("refresh_token"); but I get null.
Any ideas what could the potential reasons be for not getting the refresh tokens please?
OK. I managed to solve this one. My problem was the exact one highlighted at https://github.com/AzureAD/microsoft-identity-web/issues/1803.
The resolution was found at https://github.com/AzureAD/microsoft-identity-web/wiki/customization#how-to-query-microsoft-graph-on-token-validated