I use IdentityModel.OidcClient to get access_token. After login in browser I call OidcClient.ProcessResponseAsync() to get the LoginResult with the RefreshTokenHandler (and tokens, timestamps, user/claims). Now I create a HttpClient with the RefreshTokenHandler to call my WebApis.
var state = await oidcClient.PrepareLoginAsync();
OpenBrowser(state.StartUrl);
// ...
var loginResult = await client.ProcessResponseAsync($"?code={context.Request.QueryString.Get("code")}&state={state.State}", state);
var httpClient = new HttpClient(loginResult.RefreshTokenHandler);
// await httpClient.GetAsync(...);
Every time the access_token expires the WebApis return the HTTP status 401 (unauthorized). The RefreshTokenHandler uses the refresh_token to create a new access_token and repeats the request. So far everything works fine.
Now I persist the refresh_token, restart my application and want to use the refresh_token to get a clean LoginResult with the RefreshTokenHandler (and tokens, timestamps, user/claims) to create a HttpClient.
How can I do that? Is there a way without to fork IdentityModel.OidcClient.