dotnet core3.1 ocleot集成IdentityServer4 error:" Client has NOT been authenticated for /user and pipeline error set."
最近在看腾飞大佬的asp.net core 微服务实战遇到了ocelot集成identity server4认证时一直给报错:
warn: Ocelot.Authentication.Middleware.AuthenticationMiddleware[0]requestId: 0HM2ME7808IH4:00000009, previousRequestId: no previous request id, message: Client has NOT been authenticated for /user and pipeline error set. Request for authenticated route /user by was unauthenticated
warn: Ocelot.Responder.Middleware.ResponderMiddleware[0]
requestId: 0HM2ME7808IH4:00000009, previousRequestId: no previous request id, message: Error Code: UnauthenticatedError Message: Request for authenticated route /user by was unauthenticated errors found in ResponderMiddleware. Setting error response for request path:/user, request method: GET
一直不知道问题出来哪里,小弟请求园子里各位大佬给指点一下
首先给出错误:
项目结构如下:
【Gateway.API】中Ocelot.json配置如下:
{"Routes": [
{
"DownstreamPathTemplate": "/api/user",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5001
}
],
"UpstreamPathTemplate": "/user",
"UpstreamHttpMethod": [ "Get" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "finbook",
"AllowedScopes": []
}
}
],
"GlobalConfiguration": {
"BaseUrl": "http://localhost:5000"
}
}
【Gateway.API】中Startup.cs配置如下:
PostMan 请求:
回答
identityServer4 最新版本的 需要配置APISCOPE,老版本 只需要配置APIResource即可。不知道你有没有配。
详细可见 is4 文档 Resource章节
以上是 dotnet core3.1 ocleot集成IdentityServer4 error:" Client has NOT been authenticated for /user and pipeline error set." 的全部内容, 来源链接: utcz.com/a/46083.html