ProfileDataRequestContext.RequestedClaimTypes 在请求 API 资源以外的范围时始终为空?

ProfileDataRequestContext.RequestedClaimTypes is always null when requesting scopes other than API resources?

为什么ProfileDataRequestContext.RequestedClaimTypes为空,当请求的键值对scopes没有API资源(但身份等其他东西资源 - openid、配置文件、phone 等)

为什么不计入"Requested"?那么如何知道将要生成的 JWT 中包含哪些声明?

显然,如果我请求 API 资源并且我的所有声明都列在 UserClaims 的 属性 下,一切都会按预期进行. (其中列出的声明已添加到 requestedClaimTypes 集合中。)

谢谢!

创建令牌时调用 ProfileService,但上下文不同:

  • Context.Caller = ClaimsProviderAccessToken
  • Context.Caller = UserInfoEndpoint

所以这取决于生成的令牌类型。

对于访问令牌,只允许资源范围(ApiResources),对于返回的身份令牌,只允许身份范围(IdentityResources).

尽管默认情况下 id_token 将仅包含 sub 声明。可以在 UserInfo 端点请求其他信息。