public async static Task OnTokenIssuanceStartEvent()

in Functions.Templates/Templates/AuthenticationEventsTrigger-CSharp/AuthenticationEventsTriggerCSharp.cs [20:47]


        public async static Task<AuthenticationEventResponse> OnTokenIssuanceStartEvent(
            [AuthenticationEventsTrigger] TokenIssuanceStartRequest request, ILogger log)
        {
            try
            {
                //Is the request successful and did the token validation pass.
                if (request.RequestStatus == RequestStatusType.Successful)
                {
                    // Fetch information about user from external data store

                    //Add new claims to the token's response
                    request.Response.Actions.Add(new ProvideClaimsForToken(
                                                  new TokenClaim("DateOfBirth", "01/01/2000"),
                                                  new TokenClaim("CustomRoles", "Writer", "Editor")
                                              ));
                }
                else
                {
                    //If the request failed for any reason, i.e. Token validation, output the failed request status
                    log.LogInformation(request.StatusMessage);
                }
                return await request.Completed();
            }
            catch (Exception ex)
            {
                return await request.Failed(ex);
            }
        }