Browse Source

fix invalid_scope error invalid_request

pull/1617/head
GreenShadeZhang 3 years ago
parent
commit
6744532183
2 changed files with 26 additions and 0 deletions
  1. +16
    -0
      src/Services/Identity/Identity.API/Configuration/Config.cs
  2. +10
    -0
      src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs

+ 16
- 0
src/Services/Identity/Identity.API/Configuration/Config.cs View File

@ -20,6 +20,21 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
};
}
// ApiScope is used to protect the API
//The effect is the same as that of API resources in IdentityServer 3.x
public static IEnumerable<ApiScope> GetApiScopes()
{
return new List<ApiScope>
{
new ApiScope("orders", "Orders Service"),
new ApiScope("basket", "Basket Service"),
new ApiScope("mobileshoppingagg", "Mobile Shopping Aggregator"),
new ApiScope("webshoppingagg", "Web Shopping Aggregator"),
new ApiScope("orders.signalrhub", "Ordering Signalr Hub"),
new ApiScope("webhooks", "Webhooks registration Service"),
};
}
// Identity resources are data like user ID, name, or email address of a user
// see: http://docs.identityserver.io/en/release/configuration/resources.html
public static IEnumerable<IdentityResource> GetResources()
@ -101,6 +116,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
RequireConsent = false,
AllowOfflineAccess = true,
AlwaysIncludeUserClaimsInIdToken = true,
RequirePkce = false,
RedirectUris = new List<string>
{
$"{clientsUrl["Mvc"]}/signin-oidc"


+ 10
- 0
src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs View File

@ -76,6 +76,16 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
await context.SaveChangesAsync();
}
if (!context.ApiScopes.Any())
{
foreach (var apiScope in Config.GetApiScopes())
{
context.ApiScopes.Add(apiScope.ToEntity());
}
await context.SaveChangesAsync();
}
}
}
}

Loading…
Cancel
Save