I add the following options in appsettings.json
"OpenIdConnect": {
"ResponseType": "code id_token token",
"Scope": [ "offline_access", "https://xxx.onmicrosoft.com/5969af44-e92c-44d1-8b45-9890304d1c19/Management" ],
"SaveTokens": "true" // Save access token and refresh token
`}
and the following to the ConfigureServices(IServiceCollection services) method in Startup.cs
services.Configure<OpenIdConnectOptions>(AzureADB2CDefaults.OpenIdScheme, options =>
{
Configuration.Bind("OpenIdConnect", options);
}
Then use the following call to get new access token in my razor page
var accessToken = HttpContext.GetTokenAsync("access_token").Result;
The saved refresh token is being used behind the scene to get that new access token.