Starts in:
3 DAYS
3 HRS
37 MIN
37 SEC
Starts in:
3 D
3 H
37 M
37 S
Open Closed

AzureOpenId giving exception after redirect back app #8323


User avatar
0
apxsl created
  • ABP Framework version: v8.3.4
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
* System.InvalidOperationException: An invalid request URI was provided. Either the request URI must be an absolute URI or BaseAddress must be set.
   at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request)
   at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.RedeemAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest)
   at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleRemoteAuthenticateAsync()


* Microsoft.AspNetCore.Authentication.AuthenticationFailureException: An error was encountered while handling the remote login.
 ---> System.InvalidOperationException: An invalid request URI was provided. Either the request URI must be an absolute URI or BaseAddress must be set.
   at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request)
   at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.RedeemAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest)
   at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleRemoteAuthenticateAsync()
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
   at Volo.Abp.Account.Public.Web.ExternalProviders.AbpAccountAuthenticationRequestHandler`2.HandleRequestAsync()
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
* **Steps to reproduce the issue**:
* Setup Azure AD connection 
  .AddOpenIdConnect("AzureOpenId", "Azure AD", options =>
 {
     options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
     options.RequireHttpsMetadata = false;
     options.SaveTokens = false;
     options.GetClaimsFromUserInfoEndpoint = false;
     options.Scope.Add("email");
     options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub");
     options.SignInScheme = IdentityConstants.ExternalScheme;
     options.CallbackPath = "/callback";
     options.TokenValidationParameters = new TokenValidationParameters
     {
         ValidateIssuer = false,
         ValidateAudience = false,          
        // NameClaimType = "name",
         ValidateIssuerSigningKey = false,
         RequireSignedTokens = false,
         SignatureValidator = delegate (string token, TokenValidationParameters parameters)
         {
             var jwt = new JsonWebToken(token);
             return jwt;            
         }
     };
 })
 .WithDynamicOptions<OpenIdConnectOptions, OpenIdConnectHandler>(
     "AzureOpenId",
     options =>
     {
         options.WithProperty(x => x.Authority);
         options.WithProperty(x => x.ClientId);
         options.WithProperty(x => x.ClientSecret, isSecret: true);
     }

Exception occur after login and came back to Call back.


No answer yet!
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06