首页 文章

如何在身份服务器4 /身份验证代码流中请求访问令牌的附加声明?

提问于
浏览
0

您如何在身份服务器4 /身份验证代码流中请求访问令牌jwt的额外声明?我的自定义配置文件服务在我的身份验证代码流登录期间始终显示RequestedClaimTypes为0,因此生成的访问令牌jwt具有我的主题声明但没有名字,姓氏或电子邮件声明 .

以下是我从客户端请求的范围:“TestApi openid profile email”

这是我在身份服务器上的客户端定义:

new Client {                    
                ClientId = "authorizationCodeClient2",
                ClientName = "Authorization Code Test",
                ClientSecrets = {
                                        new Secret("secret".Sha256())
                                },
                Enabled = true,
                AllowedGrantTypes = GrantTypes.Code,
                RequireConsent = true,
                AllowRememberConsent = false,
                RedirectUris =
                new List<string> {
                 "http://localhost:5436/account/oAuth2"
                },                    
                AllowedScopes = { "TestApi", "openid", "profile", "email" },
                AccessTokenType = AccessTokenType.Jwt
            }

使用https://github.com/bayardw/IdentityServer4.Authorization.Code作为测试客户端 .

1 回答

  • 0

    我发现身份服务器将允许您选择使用用户配置文件声明标记id令牌(而不是必须调用userinfo endpoints ) . 您基本上为该特定客户端设置了一个布尔属性:

    AlwaysIncludeUserClaimsInIdToken = true;

    请注意,您需要在身份验证请求中请求以下范围:( openid Profiles 电子邮件)

相关问题