I keep getting Invalid Scope error in IdentityServer4 after I Authorize through swaggerui
I tried using these configurations
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"
}
},
and the following configuration on the 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 recognizes the client, but doesn't seem to get the webapi scope.I keep getting Invalid scope. What am I missing?
You need to make sure webapi
is a valid API resource scope. Most likely you haven't configured this API resource yet. Add the below to wherever your API resource configuration information is stored on the Identity Server 4 side.
new ApiResource("webapi", "My API");