本篇文章為大家探討IdentityServer4 授權(quán)配置AllowedScopes的方法的解決方法,文章內(nèi)容質(zhì)量較高,有需要的朋友可以學習和借鑒。
IdentityServer4 授權(quán)配置Client
中的AllowedScopes
,設置的是具體的 API 站點名字,也就是使用方設置的ApiName
,示例代碼:
//授權(quán)中心配置new Client { ClientId = "client_id_1", AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, AllowOfflineAccess = true, AccessTokenLifetime = 3600 * 6, //6小時SlidingRefreshTokenLifetime = 1296000, //15天ClientSecrets = {new Secret("secret".Sha256()) }, AllowedScopes = {"api_name1"}, }//API 服務配置app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions { Authority = $"http://localhost:5000", ApiName = "api_name1", RequireHttpsMetadata = false});