///<inheritdoc/> protected override async Task RenewAccessTokenAsync() { AuthenticationResult result; try { result = await PublicClient.AcquireTokenSilent(ApiTokenAccessArgs.Scopes, ApiTokenAccessArgs.UserAccount).ExecuteAsync(); if (string.IsNullOrEmpty(result.AccessToken)) { throw new MsalUiRequiredException("404", "Access token was null"); } } catch (MsalUiRequiredException) { result = await PublicClient.AcquireTokenInteractive(ApiTokenAccessArgs.Scopes) .WithB2CAuthority(AuthoritySUSI) .WithAccount(ApiTokenAccessArgs.UserAccount) .WithParentActivityOrWindow(Context.GetMainWindow()) .ExecuteAsync() .ConfigureAwait(false); } catch { throw; } AccessToken = AccessToken.Bearer(result.AccessToken, result.ExpiresOn); IdToken = result.IdToken; TokenRenewed?.Invoke(result); }
/// <summary> /// Fire the <see cref="TokenRenewed"/> event. /// </summary> /// <param name="e"></param> protected virtual void OnTokenRenewed(TokenRenewedEventArgs e) { TokenRenewed?.Invoke(this, e); }