Asp.net web api 在IdentityServer3中,如果还请求了访问令牌,为什么所有身份声明都被排除在id_令牌之外?

Asp.net web api 在IdentityServer3中,如果还请求了访问令牌,为什么所有身份声明都被排除在id_令牌之外?,asp.net-web-api,identityserver3,Asp.net Web Api,Identityserver3,在进行自定义实现时,我一直在查看IdentityServer3的源代码。我在尝试向id_令牌添加声明时遇到问题。我遇到了这段代码: //来自AuthorizeResponseGenerator.cs,方法CreateImplicitFlowResponseAsync 字符串jwt=null; if(responseTypes.Contains(Constants.responseTypes.IdToken)) { var tokenRequest=新TokenCreationRequest {

在进行自定义实现时,我一直在查看IdentityServer3的源代码。我在尝试向id_令牌添加声明时遇到问题。我遇到了这段代码:

//来自AuthorizeResponseGenerator.cs,方法CreateImplicitFlowResponseAsync
字符串jwt=null;
if(responseTypes.Contains(Constants.responseTypes.IdToken))
{
var tokenRequest=新TokenCreationRequest
{
ValidatedRequest=请求,
主题=请求。主题,
Client=request.Client,
Scopes=request.ValidatedScopes.GrantedScopes,
Nonce=request.Raw.Get(Constants.AuthorizeRequest.Nonce),

IncludeAllIdentityClaims=!request.AccessTokenRequested,//因为规范就是这样写的——它是为了优化令牌大小。我们在作用域声明中有一个名为
AlwaysIncludeInIdToken
的设置来禁用此优化。

我刚刚通过您在这里的评论发现了这一点。根据您所说的,OIDC定义了这一点规格。据我所知,如果您只要求id_代币,则将要求所有索赔。谢谢!
 //From AuthorizeResponseGenerator.cs, method CreateImplicitFlowResponseAsync
 string jwt = null;
 if (responseTypes.Contains(Constants.ResponseTypes.IdToken))
 {
     var tokenRequest = new TokenCreationRequest
     {
           ValidatedRequest = request,
           Subject = request.Subject,
           Client = request.Client,
           Scopes = request.ValidatedScopes.GrantedScopes,

           Nonce = request.Raw.Get(Constants.AuthorizeRequest.Nonce),
           IncludeAllIdentityClaims = !request.AccessTokenRequested, // <---- This line
           AccessTokenToHash = accessTokenValue,
           AuthorizationCodeToHash = authorizationCode
      };