Swagger 无效的范围扩展和标识服务器4
通过swaggerui进行授权后,IdentityServer4中不断出现无效范围错误 我试着使用这些配置Swagger 无效的范围扩展和标识服务器4,swagger,identityserver4,swagger-ui,Swagger,Identityserver4,Swagger Ui,通过swaggerui进行授权后,IdentityServer4中不断出现无效范围错误 我试着使用这些配置 new Client { ClientId = "swaggerui", ClientName = "Swagger UI", AllowedGrantTypes = GrantTypes.Implicit, AllowAccessTokensViaBrowser = true, Re
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"
}
},
以及在SwiggerUI上的以下配置
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"
}
}
});
c.AddSecurityDefinition(“oauth2”),新的oauth2模式
{
Type=“oauth2”,
Flow=“隐式”,
授权URL=”http://localhost:5000/connect/authorize",
令牌URL=”http://localhost:5000/connect/token",
范围=新字典
{
{
“webapi”、“我的API”
}
}
});
IdentityServer识别客户端,但似乎没有得到webapi作用域。我一直得到无效的作用域。
我缺少什么?您需要确保
webapi
是一个有效的API资源范围。很可能您尚未配置此API资源。将以下内容添加到Identity Server 4端存储API资源配置信息的位置
new ApiResource("webapi", "My API");
您是如何在C#应用程序中配置IdentityServer的?您是否在IdentityServer的资源存储中注册了这些自定义作用域?您可以在“AddIdentityServer”之后使用“AddInMemoryApiResources”扩展方法,如果您没有该扩展方法。。。谢谢