private async Task <AuthenticationTicket> CreateTicketAsync(string token) { var ticket = await DecryptTokenAsync(token); if (ticket == null) { return(null); } if (Options.SaveToken) { // Store the access token in the authentication ticket. ticket.Properties.Dictionary[OAuthValidationConstants.Properties.Token] = token; } // Copy the scopes extracted from the authentication ticket to the // ClaimsIdentity to make them easier to retrieve from application code. var scopes = ticket.Properties.GetProperty(OAuthValidationConstants.Properties.Scopes); if (!string.IsNullOrEmpty(scopes)) { foreach (var scope in JArray.Parse(scopes).Values <string>()) { ticket.Identity.AddClaim(new Claim(OAuthValidationConstants.Claims.Scope, scope)); } } var notification = new CreateTicketContext(Context, Options, ticket); await Options.Events.CreateTicket(notification); return(notification.Ticket); }
/// <summary> /// Invoked when a ticket is to be created from an access token. /// </summary> public virtual Task CreateTicket(CreateTicketContext context) => OnCreateTicket(context);