private async Task <AuthenticationTicket> DeserializeRefreshTokenAsync(string token, OpenIdConnectRequest request) { var notification = new DeserializeRefreshTokenContext(Context, Scheme, Options, request, token) { DataFormat = Options.RefreshTokenFormat }; await Provider.DeserializeRefreshToken(notification); if (notification.IsHandled || notification.Ticket != null) { notification.Ticket?.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); return(notification.Ticket); } if (notification.DataFormat == null) { throw new InvalidOperationException("A data formatter must be provided."); } var ticket = notification.DataFormat.Unprotect(token); if (ticket == null) { Logger.LogTrace("The received token was invalid or malformed: {Token}.", token); return(null); } // Note: since the data formatter relies on a data protector using different "purposes" strings // per token type, the ticket returned by Unprotect() is guaranteed to be a refresh token. ticket.SetTokenUsage(OpenIdConnectConstants.TokenUsages.RefreshToken); Logger.LogTrace("The refresh token '{Token}' was successfully validated using " + "the specified token data format: {Claims} ; {Properties}.", token, ticket.Principal.Claims, ticket.Properties.Items); return(ticket); }
/// <summary> /// Represents an event called when deserializing a refresh token. /// </summary> /// <param name="context">The context instance associated with this event.</param> /// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns> public virtual Task DeserializeRefreshToken(DeserializeRefreshTokenContext context) => OnDeserializeRefreshToken(context);