获得identity Server4当前用户的角色

服务器端配置:

                    Client oneResult = new Client
                    {
                        ClientId = client.ClientId,
                        ClientName = client.ClientName,
                        AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                        ClientSecrets = { new Secret("111111".Sha256()) },
                        AllowOfflineAccess = true,
                        RequireConsent = false,
                        RequireClientSecret = false,
                        AllowedScopes =
                        {
                            IdentityServerConstants.StandardScopes.OpenId,
                            IdentityServerConstants.StandardScopes.Profile,
                            IdentityServerConstants.StandardScopes.OfflineAccess,
                            "role"
                        },
                        AuthorizationCodeLifetime = 36000,
                        IdentityTokenLifetime = 36000,
                        UserSsoLifetime = 36000
                    };

API地址:

http://localhost:5000/connect/userinfo

postman调用截图:

 

posted @ 2021-05-04 19:15  星星c#  阅读(265)  评论(0编辑  收藏  举报