private async Task <string> CreateCodeAsync(ValidatedAuthorizeRequest request) { var code = new AuthorizationCode { ClientId = request.Client.ClientId, Lifetime = request.Client.AuthorizationCodeLifetime, Subject = request.Subject, SessionId = request.SessionId, CodeChallenge = request.CodeChallenge.Sha256(), CodeChallengeMethod = request.CodeChallengeMethod, IsOpenId = request.IsOpenIdRequest, RequestedScopes = request.ValidatedScopes.GrantedScopes.Select(a => a.Name), RedirectUri = request.RedirectUri, Nonce = request.Nonce, WasConsentShown = request.WasConsentShown, }; // store id token and access token and return authorization code var id = CryptoRandom.CreateUniqueId(); await _grants.StoreAuthorizationCodeAsync(id, code); await RaiseCodeIssuedEventAsync(id, code); return(id); }