/// <summary> /// Processes authentication. /// </summary> /// <returns>The authenticate result.</returns> protected override async Task <AuthenticateResult> HandleAuthenticateAsync() { var client = await ControllerExtensions.GetResourceAccessClientAsync(Request); if (!client.IsUserSignedIn) { return(AuthenticateResult.Fail(new UnauthorizedAccessException(client.Token?.ErrorDescription ?? "No content to login or invalid access token."))); } var principal = new OnPremisesPrincipal(client); return(AuthenticateResult.Success(new AuthenticationTicket(principal, "bearer"))); }