Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Identityserver4 面临OpenIdConnectProtocolException:无效的\u令牌错误_Identityserver4_.net Core 3.1 - Fatal编程技术网

Identityserver4 面临OpenIdConnectProtocolException:无效的\u令牌错误

Identityserver4 面临OpenIdConnectProtocolException:无效的\u令牌错误,identityserver4,.net-core-3.1,Identityserver4,.net Core 3.1,我有一个主应用程序(MainApp)和一个客户端应用程序(clientApp)。我正在尝试通过MainApp登录ClientApp。(在ClientApp中有一个登录按钮,它将转到MainApp进行登录)。我在Startup.cs文件中进行了如下设置: services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.Authent

我有一个主应用程序(MainApp)和一个客户端应用程序(clientApp)。我正在尝试通过MainApp登录ClientApp。(在ClientApp中有一个登录按钮,它将转到MainApp进行登录)。我在Startup.cs文件中进行了如下设置:

services.AddAuthentication(options =>
        {
            options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            options.DefaultChallengeScheme = "oidc";
        })
        .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme)
        .AddOpenIdConnect("oidc", "OneIAM", options =>
        {
            options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            options.Authority = "https://localhost:5001";
            options.ClientId = "XXXXXX858";
            options.ClientSecret = "XXXXXXXXXXXXXXXXHDDH6os6/xJr7qGmmSJQxViHiq585KdghDaLnQ1Rb03J==";

            options.CallbackPath = "/Index";
            options.SignedOutRedirectUri = "https://localhost:5001/signout-callback-oidc";

            options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
            options.SaveTokens = true;
            options.GetClaimsFromUserInfoEndpoint = true;

            options.Scope.Add("openid");
            options.Scope.Add("profile");

            options.ResponseType = "code";
            options.SaveTokens = true;
        });
在上述代码中,”https://localhost:5001“是MainApp的URL

我已使用以下代码在MainApp中注册了ClientId和ClientSecret:

dotnet user-secrets set 'HttpClient:CbApi:ClientId' 'XXXX858'
dotnet user-secrets set 'HttpClient:CbApi:ClientSecret' 'XXXXXXXXXXXXXXXXHDDH6os6/xJr7qGmmSJQxViHiq585KdghDaLnQ1Rb03J=='
现在,在运行了两个(MainApp和ClientApp)之后,我在ClientApp上有了登录按钮,在点击登录按钮之后,它将重定向到MainApp登录页面。但是,在提供凭证并点击登录按钮后,它会显示错误,如下所示

An unhandled exception occurred while processing the request.

OpenIdConnectProtocolException: Message contains error: 'invalid_client', error_description: 'error_description is null', error_uri: 'error_uri is null'.
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.RedeemAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest)

Exception: An error was encountered while handling the remote login.
Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler<TOptions>.HandleRequestAsync()
处理请求时发生未处理的异常。
OpenIdConnectProtocolException:消息包含错误:“无效的客户端”,错误描述:“错误描述为null”,错误uri:“错误uri为null”。
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.ReceiveAuthorizationCodeAsync(OpenIdConnectMessage tokenEndpointRequest)
异常:处理远程登录时遇到错误。
Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler.HandlerRequestAsync()
仅供参考:我还维护了数据库表中的所有客户信息


请在这方面帮助我,如果您还需要什么,请告诉我。

客户端数据库中该客户端ID的条目是什么样子的?实际上,实际的客户端ID有点不同,并且双方(Startup.cs和database)都有相同的客户端ID。在成功登录MainApp后,我正在尝试重定向ClientApp中的索引页。如果您的客户端无效,则客户端中的客户端ID与IdentityServer认为的客户端ID不同。。。。我会在数据库层中添加更多日志记录或单步操作。请您分享一些代码,在这种情况下可以帮助我。一个起点可以是使用InMemory客户机/资源存储,当它起作用时,移动到使用数据库。否则,这里有很多错误源。