我遇到此错误:
只有删除重定向后,我才能成功访问
这是Identity Server 4的一面:
new Client {
RequireConsent = false,
ClientId = "ClientApp",
ClientName = "SPA Client App",
AccessTokenType = AccessTokenType.Jwt,
AllowedGrantTypes = GrantTypes.Implicit,
AllowedScopes = { "openid", "profile", "email", "api.read" },
RedirectUris = {"http://localhost:4200/auth-callback"},
PostLogoutRedirectUris = {"http://localhost:4200/"},
AllowedCorsOrigins = {"http://localhost:4200"},
AllowAccessTokensViaBrowser = true,
AccessTokenLifetime = 3600
},
和客户端:
export function getClientSettings(): UserManagerSettings {
return {
authority: 'http://localhost:5000',
client_id: 'ClientApp',
redirect_uri: 'http://localhost:4200/auth-callback',
post_logout_redirect_uri: 'http://localhost:4200/',
response_type: 'id_token token',
// scope: 'openid profile BankOfDotNet.API',
scope: 'openid profile email api.read',
filterProtocolClaims: true,
loadUserInfo: true,
automaticSilentRenew: true,
silent_redirect_uri: 'http://localhost:4200/silent-refresh.html'
};
}
正在显示另一个错误,我不知道它是否与以前的错误相同。
询问的日志:
IdentityServer4.Validation.AuthorizeRequestValidator:Error: Unknown client or not enabled: SPAClient
{
"SubjectId": "anonymous",
"RequestedScopes": "",
"Raw": {
"client_id": "SPAClient",
"redirect_uri": "http://localhost:4200/fetch-data",
"response_type": "code",
"scope": "openid profile bankOfDotNetApi",
"state": "b1c4a9eebe704650a6301a4fa633d558",
"code_challenge": "OWv8xEW0iHKVQTDUTqxybVe4cQXAd2mdJIWZ8Budni8",
"code_challenge_method": "S256",
"response_mode": "query"
}
}
IdentityServer4.Endpoints.AuthorizeEndpoint:Error: Request validation failed
IdentityServer4.Endpoints.AuthorizeEndpoint:Information: {
"SubjectId": "anonymous",
"RequestedScopes": "",
"Raw": {
"client_id": "SPAClient",
"redirect_uri": "http://localhost:4200/fetch-data",
"response_type": "code",
"scope": "openid profile bankOfDotNetApi",
"state": "b1c4a9eebe704650a6301a4fa633d558",
"code_challenge": "OWv8xEW0iHKVQTDUTqxybVe4cQXAd2mdJIWZ8Budni8",
"code_challenge_method": "S256",
"response_mode": "query"
}
}
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 186.6231ms 302
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:5000/home/error?errorId=CfDJ8CQhqAOzyZ9FnWMOkakiUDM48vI_2dxE-C2BufLYKmWsaswgqMctLthhXKjSgwSdgWakjV1UpkzAwMl4aeQRoa_OK7NBBmGejbq8r8kZ8ZryGFMBXhFPTP_auWF6ZU0qSRpm6hRYKpaFsJkA9V0mbmpcHeHTok7levfWugV3Ysiu0xRCRYz7iSM590AlkEjiHCLjrFnGTaGTY7pFGywlcfeWbeOpfkbBVNqeqe0YgkJzFmBouS4k7XdOhAL6afG8j2Zh33Cw4yDMYFMEXIOLWswYoHy2Q0t4G5gpJ2VBBoIgtRV2LeVHrw45qpIUjNOFNnI1g-rD_eTgb0pCjXCLJfR_X6zIO1tJArXHrUTLyAMt
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Route matched with {action = "Error", controller = "Home"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Error(System.String) on controller IdentityServer4.Quickstart.UI.HomeController (BankOfDotNet.IdentitySvr).
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method IdentityServer4.Quickstart.UI.HomeController.Error (BankOfDotNet.IdentitySvr) - Validation state: Valid
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action method IdentityServer4.Quickstart.UI.HomeController.Error (BankOfDotNet.IdentitySvr), returned result Microsoft.AspNetCore.Mvc.ViewResult in 7.5635ms.
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor:Information: Executing ViewResult, running view Error.
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor:Information: Executed ViewResult - view Error executed in 21.4364ms.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action IdentityServer4.Quickstart.UI.HomeController.Error (BankOfDotNet.IdentitySvr) in 50.3452ms
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 72.7919ms 200 text/html; charset=utf-8
The thread 0x2c44 has exited with code 0 (0x0).
The thread 0x46d0 has exited with code 0 (0x0).
即时通讯,这就是为什么我们这样添加日志的原因,我不知道如何在最简单的视图中添加日志。
答案 0 :(得分:0)
您的客户定义说
ClientId = "ClientApp",
但是在日志中,却说:
"client_id": "SPAClient",
您对clientId感到困惑吗?