Open Closed

OpenIdDict issue #5311


User avatar
0
nguyenngoc.son created
  • ABP Framework version: v7.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: I can not generate token when calling API "connect/token"
  • Steps to reproduce the issue:"

3 Answer(s)
  • User Avatar
    0
    Long.Nguyen created

    Hi,

    Could you please provide some more information, sample code ? Thank you.

    Regards, Long

  • User Avatar
    0
    nguyenngoc.son created

    H, There is nothing specfic about the code base. I was follow the instruction in ABP document page. When calling the connect/token API, I receive the log below

    [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ExtractTokenRequest". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateGrantType". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateClientIdParameter". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateAuthorizationCodeParameter". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateClientCredentialsParameters". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateDeviceCodeParameter". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateRefreshTokenParameter". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateResourceOwnerCredentialsParameters". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateScopeParameter". [10:59:29 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateProofKeyForCodeExchangeParameters". [10:59:31 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateScopes". [10:59:31 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateClientId". [10:59:31 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateClientType". [10:59:31 DBG] [] The event "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" was successfully processed by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateClientSecret". [10:59:31 DBG] [] An exception was thrown by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateEndpointPermissions" while handling the "OpenIddict.Server.OpenIddictServerEvents+ValidateTokenRequestContext" event. System.Text.Json.JsonReaderException: '0x0A' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 0 | BytePositionInLine: 253. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate(ReadOnlySpan1 data, Int32 idx) at System.Text.Json.Utf8JsonReader.ConsumeString() at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ConsumeNextToken(Byte marker) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) at Volo.Abp.OpenIddict.Applications.AbpOpenIddictApplicationStore.GetPermissionsAsync(OpenIddictApplicationModel application, CancellationToken cancellationToken) at OpenIddict.Core.OpenIddictApplicationManager1.GetPermissionsAsync(TApplication application, CancellationToken cancellationToken) at OpenIddict.Core.OpenIddictApplicationManager1.HasPermissionAsync(TApplication application, String permission, CancellationToken cancellationToken) at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ValidateEndpointPermissions.HandleAsync(ValidateTokenRequestContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) [10:59:31 DBG] [] An exception was thrown by "OpenIddict.Server.OpenIddictServerHandlers+Exchange+ValidateTokenRequest" while handling the "OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext" event. System.Text.Json.JsonReaderException: '0x0A' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 0 | BytePositionInLine: 253. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate(ReadOnlySpan1 data, Int32 idx) at System.Text.Json.Utf8JsonReader.ConsumeString() at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ConsumeNextToken(Byte marker) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) at Volo.Abp.OpenIddict.Applications.AbpOpenIddictApplicationStore.GetPermissionsAsync(OpenIddictApplicationModel application, CancellationToken cancellationToken) at OpenIddict.Core.OpenIddictApplicationManager1.GetPermissionsAsync(TApplication application, CancellationToken cancellationToken) at OpenIddict.Core.OpenIddictApplicationManager1.HasPermissionAsync(TApplication application, String permission, CancellationToken cancellationToken) at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ValidateEndpointPermissions.HandleAsync(ValidateTokenRequestContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ValidateTokenRequest.HandleAsync(ProcessRequestContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) [10:59:32 ERR] [] An unhandled exception has occurred while executing the request. System.Text.Json.JsonReaderException: '0x0A' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 0 | BytePositionInLine: 253. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate(ReadOnlySpan1 data, Int32 idx) at System.Text.Json.Utf8JsonReader.ConsumeString() at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ConsumeNextToken(Byte marker) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) at Volo.Abp.OpenIddict.Applications.AbpOpenIddictApplicationStore.GetPermissionsAsync(OpenIddictApplicationModel application, CancellationToken cancellationToken) at OpenIddict.Core.OpenIddictApplicationManager1.GetPermissionsAsync(TApplication application, CancellationToken cancellationToken) at OpenIddict.Core.OpenIddictApplicationManager`1.HasPermissionAsync(TApplication application, String permission, CancellationToken cancellationToken) at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ValidateEndpointPermissions.HandleAsync(ValidateTokenRequestContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.OpenIddictServerHandlers.Exchange.ValidateTokenRequest.HandleAsync(ProcessRequestContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context) at OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandler.HandleRequestAsync() at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at SCV.Litmus.Shared.DecryptHttpHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in D:\TASConnect\SourceCode\core-platform\SCV.Litmus\aspnet-core\shared\SCV.Litmus.Shared\Middleware\DecryptHttpHeadersMiddleware.cs:line 51 at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<

  • User Avatar
    0
    Long.Nguyen created

    Hi,

    Could you provide the request payload ?

    Please double check if it has any values which contain special characters, for example: "\"

    Thanks.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19