Open Closed

RefreshToken send error #5780


User avatar
0
douglasmolon@gmail.com created
  • ABP Framework version: v7.2.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: Below
  • Steps to reproduce the issue:Below

Hello,

We are encountering a strange problem when trying to send a refresh token. It seems that the OpenIddict Module or .NET won't accept the length of the refresh token. The endpoint is returning the following error: "Form key length limit 2048 exceeded." The question is: Should we set the form value limit to accommodate the refresh token, or is there a way to compress its size?

Exception: [auth-server_1de50682-b]: [18:18:48 INF] Request starting HTTP/1.1 POST https://127.0.0.1:44322/connect/token application/x-www-form-urlencoded 4619 [auth-server_1de50682-b]: [18:18:48 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessRequestContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ResolveRequestUri. [auth-server_1de50682-b]: [18:18:48 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ResolveRequestUri. [auth-server_1de50682-b]: [18:18:48 INF] The request URI matched a server endpoint: Token. [auth-server_1de50682-b]: [18:18:48 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.OpenIddictServerHandlers+InferEndpointType. [auth-server_1de50682-b]: [18:18:48 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by Volo.Abp.Account.Web.Pages.Account.OpenIddictImpersonateInferEndpointType. [auth-server_1de50682-b]: [18:18:48 DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ValidateHostHeader. [auth-server_1de50682-b]: [18:18:48 DBG] An exception was thrown by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ExtractPostRequest`1[[OpenIddict.Server.OpenIddictServerEvents+ExtractTokenRequestContext, OpenIddict.Server, Version=4.2.0.0, Culture=neutral, PublicKeyToken=35a561290d20de2f]] while handling the OpenIddict.Server.OpenIddictServerEvents+ExtractTokenRequestContext event. [auth-server_1de50682-b]: System.IO.InvalidDataException: Form key length limit 2048 exceeded. [auth-server_1de50682-b]: at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ThrowKeyTooLargeException() [auth-server_1de50682-b]: at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ParseValuesSlow(ReadOnlySequence`1& buffer, KeyValueAccumulator& accumulator, Boolean isFinalBlock) [auth-server_1de50682-b]: at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ParseFormValues(ReadOnlySequence`1& buffer, KeyValueAccumulator& accumulator, Boolean isFinalBlock) [auth-server_1de50682-b]: at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ReadFormAsync(CancellationToken cancellationToken) [auth-server_1de50682-b]: at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken) [auth-server_1de50682-b]: at OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers.ExtractPostRequest`1.HandleAsync(TContext context) [auth-server_1de50682-b]: at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) [auth-server_1de50682-b]: at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) [auth-server_1de50682-b]: at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ExtractTokenRequest.HandleAsync(ProcessRequestContext context) [auth-server_1de50682-b]: at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) [auth-server_1de50682-b]: [18:18:48 DBG] An exception was thrown by OpenIddict.Server.OpenIddictServerHandlers+Exchange+ExtractTokenRequest while handling the OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext event.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    System.IO.InvalidDataException: Form key length limit 2048 exceeded.

    You can configure the KeyLengthLimit of FormOptions.

    https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.features.formoptions.keylengthlimit?view=aspnetcore-7.0

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    douglasmolon@gmail.com created

    hi

    System.IO.InvalidDataException: Form key length limit 2048 exceeded.

    You can configure the KeyLengthLimit of FormOptions.

    https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.features.formoptions.keylengthlimit?view=aspnetcore-7.0

    It worked. Thanks!

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 09, 2026, 11:56
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.