【发布时间】:2019-12-05 17:08:28
【问题描述】:
通过 swaggerui 授权后,IdentityServer4 中不断出现 Invalid Scope 错误
我尝试使用这些配置
new Client
{
ClientId = "swaggerui",
ClientName = "Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = {"http://localhost:5001/swagger/oauth2-redirect.html"},
PostLogoutRedirectUris = {"http://localhost:5001/swagger/"},
AllowedScopes =
{
"webapi"
}
},
以及swaggerui上的如下配置
c.AddSecurityDefinition("oauth2", new OAuth2Scheme
{
Type = "oauth2",
Flow = "implicit",
AuthorizationUrl = "http://localhost:5000/connect/authorize",
TokenUrl = "http://localhost:5000/connect/token",
Scopes = new Dictionary<string, string>
{
{
"webapi", "My API"
}
}
});
IdentityServer 识别客户端,但似乎没有获得 webapi 范围。我不断收到无效范围。 我错过了什么?
【问题讨论】:
-
您是如何在 C# 应用程序中配置 IdentityServer 的?您是否在 IdentityServer 的资源存储中注册了这些自定义范围?如果您还没有,您可以在“AddIdentityServer”之后使用“AddInMemoryApiResources”扩展方法
标签: swagger identityserver4 swagger-ui