Open Closed

The token is no longer valid because the user's session expired. when use Login with this tenant on blazor server #8031


User avatar
0
castellazzi created

Check the docs before asking a question: https://abp.io/docs/latest Check the samples to see the basic tasks: https://abp.io/docs/latest/samples The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info: 🧐 Hint: If you are using the ABP Studio, you can see all the information about your solution from the configuration window, which opens when you right-click on the solution and click on the Solution Configuration button.

  • ABP Framework version: v8.2.0
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server)
  • Exception message and full stack trace
  • OpenIdConnectProtocolException: Message contains error: 'invalid_grant', error_description: 'The token is no longer valid because the user's session expired.', error_uri: 'error_uri is null'. Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.RedeemAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest) Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleRemoteAuthenticateAsync()

Show raw exception details AuthenticationFailureException: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler.HandleRequestAsync() Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Prometheus.HttpMetrics.HttpRequestDurationMiddleware.Invoke(HttpContext context) Prometheus.HttpMetrics.HttpRequestCountMiddleware.Invoke(HttpContext context) Prometheus.HttpMetrics.HttpInProgressMiddleware.Invoke(HttpContext context) Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<b__0>d.MoveNext() Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<b__0>d.MoveNext() Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<b__0>d.MoveNext() Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context) Log from authserver : [12:44:57 INF] The request URI matched a server endpoint: Authorization. 2768[12:44:57 INF] The authorization request was successfully extracted: { 2769 "client_id": "BlazorServer", 2770 "redirect_uri": "https://localhost:44314/signin-oidc";, 2771 "response_type": "code id_token", 2772 "scope": "openid profile roles email phone AccountService IdentityService AdministrationService SaasService ProductService", 2773 "response_mode": "form_post", 2774 "nonce": "638636354975130522.YzYyNTM3NDAtMTZhMS00YmY5LTlmNDItOWI1MDg2NDA1ODkzODJmOTRmNzQtNTQxNC00MDExLTkwMTAtNDg4Y2M1NDAyNzli", 2775 "access_token": "[redacted]", 2776 "tenantid": "a2564546-3834-a7a4-fcf3-3a14598c45c5", 2777 "tenantusername": "admin", 2778 "returnurl": "https://localhost:44314/Saas/Host/Tenants";, 2779 "state": "CfDJ8KoQ8VGwUkdDsYUxXZv-6E8fcA_8b5UprTYvEA1uKPZ0LmQdwcIW6DE7IMHYU1dybFTxFoz4kIAqLwRDpovpHq98_FRnm57Jdfo93ldLR2_RCEvow4HNii2ahe27iwjZyCqOBUZmBCJNWl0r66G49xfOwD6n4PIhs2tFIQKLc73F0UY-Xd5ADu32-hUWhHljbc9WNgIj_uLDVj7lLpkXJJSTI6OZ4sVYY4lgPEfz7glUIZOv8j-V_QrdD-qTBfLvLrlzCdsqP5F9BsTYKCU5V_q04Rw1tuNMOkBFJMVu0nXehJx7Hd70YvcOGQCL6wPupPwJz92mdFdCFke5JSKmVAf20E4Ym5Cauu3BlkaYTpzaE-CGq1yeZ7Ep68C76mrpAcZpG8dB2XuwbsV9ehvujxwadVPgBnpVSicyZFC3h2vv_pSO5Vy8JVaFoRUcx4DNvwP451nN0ilfHuZC_F1FoPYPZdS69ysJ839lD9GudZdi", 2780 "x-client-SKU": "ID_NET8_0", 2781 "x-client-ver": "7.5.1.0" 2782}. 2783[12:44:57 INF] The authorization request was successfully validated. 2784[12:44:57 ERR] SessionId is null. It's not possible to revoke the session. 2785[12:44:57 INF] AuthenticationScheme: Identity.Application signed out. 2786[12:44:57 INF] AuthenticationScheme: Identity.External signed out. 2787[12:44:57 INF] AuthenticationScheme: Identity.TwoFactorUserId signed out. 2788[12:44:57 INF] AuthenticationScheme: Identity.TwoFactorRememberMe signed out. 2789[12:44:57 INF] Identity.Application was not authenticated. Failure message: No principal. 2790[12:44:57 INF] Executing endpoint '/Account/ImpersonateTenant' 2791[12:44:57 INF] Route matched with {page = "/Account/ImpersonateTenant", area = "", action = "", controller = ""}. Executing page /Account/ImpersonateTenant 2792[12:44:57 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy 2793[12:44:57 INF] Executing handler method Volo.Abp.Account.Public.Web.Pages.Account.ImpersonateTenantModel.OnGetAsync - ModelState is Valid 2794[12:44:57 WRN] Could not find a session with ID: bdf1c53d-b2be-4ad5-945f-6c99bc970ee2 2795[12:44:57 WRN] SessionId(bdf1c53d-b2be-4ad5-945f-6c99bc970ee2) not found for user: 25072dcb-678d-0dae-c88b-3a14598c509b, log out. 2796[12:44:57 INF] Executed handler method OnGetAsync, returned result Microsoft.AspNetCore.Mvc.SignInResult. 2797[12:44:57 INF] Executing SignInResult with authentication scheme (OpenIddict.Server.AspNetCore) and the following principal: System.Security.Claims.ClaimsPrincipal. 2798[12:44:57 INF] Creating identity session for session id: bdf1c53d-b2be-4ad5-945f-6c99bc970ee2, device: OAuth, user id: 25072dcb-678d-0dae-c88b-3a14598c509b, tenant id: a2564546-3834-a7a4-fcf3-3a14598c45c5, client id: BlazorServer 2799[12:44:57 INF] The authorization response was successfully returned to 'https://localhost:44314/signin-oidc'; using the form post response mode: { 2800 "code": "[redacted]", 2801 "id_token": "[redacted]", 2802 "state": "CfDJ8KoQ8VGwUkdDsYUxXZv-6E8fcA_8b5UprTYvEA1uKPZ0LmQdwcIW6DE7IMHYU1dybFTxFoz4kIAqLwRDpovpHq98_FRnm57Jdfo93ldLR2_RCEvow4HNii2ahe27iwjZyCqOBUZmBCJNWl0r66G49xfOwD6n4PIhs2tFIQKLc73F0UY-Xd5ADu32-hUWhHljbc9WNgIj_uLDVj7lLpkXJJSTI6OZ4sVYY4lgPEfz7glUIZOv8j-V_QrdD-qTBfLvLrlzCdsqP5F9BsTYKCU5V_q04Rw1tuNMOkBFJMVu0nXehJx7Hd70YvcOGQCL6wPupPwJz92mdFdCFke5JSKmVAf20E4Ym5Cauu3BlkaYTpzaE-CGq1yeZ7Ep68C76mrpAcZpG8dB2XuwbsV9ehvujxwadVPgBnpVSicyZFC3h2vv_pSO5Vy8JVaFoRUcx4DNvwP451nN0ilfHuZC_F1FoPYPZdS69ysJ839lD9GudZdi", 2803 "iss": "https://localhost:44322/"; 2804}. 2805[12:44:57 INF] Executed page /Account/ImpersonateTenant in 276.386ms 2806[12:44:57 INF] Executed endpoint '/Account/ImpersonateTenant' 2807[12:44:57 INF] The request URI matched a server endpoint: Token. 2808[12:44:57 INF] The token request was successfully extracted: { 2809 "client_id": "BlazorServer", 2810 "client_secret": "[redacted]", 2811 "code": "[redacted]", 2812 "grant_type": "authorization_code", 2813 "redirect_uri": "https://localhost:44314/signin-oidc"; 2814}. 2815[12:44:58 WRN] Could not find a session with ID: bdf1c53d-b2be-4ad5-945f-6c99bc970ee2 2816[12:44:58 WRN] The token is no longer valid because the user's session expired. 2817[12:44:58 INF] The response was successfully returned as a JSON document: { 2818 "error": "invalid_grant", 2819 "error_description": "The token is no longer valid because the user's session expired." 2820}.

<br>

  • Steps to reproduce the issue
  • Using Login with this tenant

4 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello,

    Can you please try IsDynamicClaimsEnabled = false

    context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
    {
        options.IsDynamicClaimsEnabled = false;
    });
    

    Thank you.

  • User Avatar
    0
    castellazzi created

    Hi With DynamicClaims feature disabled now working fine. So I must always disable this feature "DynamicClaims", or there will be a fix/improvment in future. ? Thanks Marco

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello,

    Yes sure we will work on it and try to improve in future. Actually this seems in very rare cases. You may close the ticket if your issue is resolved.

    Thanks : ),

  • User Avatar
    0
    castellazzi created

    Thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11