Asp.net core 返回ExternalCallback时图片声明不可用

Asp.net core 返回ExternalCallback时图片声明不可用,asp.net-core,asp.net-identity,identityserver4,Asp.net Core,Asp.net Identity,Identityserver4,我正在将两个asp.net core 1.1 identityserver应用程序升级到asp.net core 2 第一个是IdentityServer A,它充当联邦网关和身份存储。第二个,IdentityServer B使用A作为外部提供程序。在我的应用程序域中,客户端应针对B进行身份验证,B对从A收到的身份提出附加声明 在这一点上,身份验证流似乎工作正常,除非B向身份添加其他声明 在服务器上,IdentityServer的配置如下: services.AddIdentityServer(

我正在将两个asp.net core 1.1 identityserver应用程序升级到asp.net core 2

第一个是IdentityServer A,它充当联邦网关和身份存储。第二个,IdentityServer B使用A作为外部提供程序。在我的应用程序域中,客户端应针对B进行身份验证,B对从A收到的身份提出附加声明

在这一点上,身份验证流似乎工作正常,除非B向身份添加其他声明

在服务器上,IdentityServer的配置如下:

services.AddIdentityServer()
    .AddDeveloperSigningCredential()
    .AddInMemoryClients(Clients.GetClients())
    .AddInMemoryIdentityResources(IdentityResources.GetIdentityResources())
    .AddAspNetIdentity<ApplicationUser>()
    .AddProfileService<ProfileService>();
我搞不懂为什么没有图片声明。欢迎提出任何建议

编辑 更多信息。在定义了.AddOpenIdConnect(“oidc”)的B上,我尝试将OnUserInformation received事件添加到options.Events。当收到用户信息时,我可以在上下文中将picture属性视为用户对象的一部分。因此,该信息是可用的,但不会作为声明添加…看起来

public async Task GetProfileDataAsync(ProfileDataRequestContext context)
{
    var user = await _userManager.GetUserAsync(context.Subject);

    // Scope: OpenId
    AddClaimIfRequested(JwtClaimTypes.Subject, context.RequestedClaimTypes, context.IssuedClaims, user.Id);

    // Scope: Profile
    AddClaimIfRequested(JwtClaimTypes.GivenName, context.RequestedClaimTypes, context.IssuedClaims, user.Firstname);
    AddClaimIfRequested(JwtClaimTypes.FamilyName, context.RequestedClaimTypes, context.IssuedClaims, user.Lastname);
    AddClaimIfRequested(JwtClaimTypes.Picture, context.RequestedClaimTypes, context.IssuedClaims, Convert.ToBase64String(user.ProfilePicture));

    // Scope: Email
    AddClaimIfRequested(JwtClaimTypes.Email, context.RequestedClaimTypes, context.IssuedClaims, user.Email);
}

private void AddClaimIfRequested(string claim, IEnumerable<string> requestedClaims, List<Claim> issuedClaims, string value)
{
    if (requestedClaims.Contains(claim))
        issuedClaims.Add(new Claim(claim, value));
}
public async Task<IActionResult> ExternalCallback(string returnUrl)
{
    //Read external identity from the tempoary cookie
    var result = await HttpContext.AuthenticateAsync(IdentityServerConstants.ExternalCookieAuthenticationScheme);
    if (result == null)
        throw new Exception("External authentication error");

    var externalUser = result.Principal;
    if (externalUser == null)
        throw new Exception("External authentication error");

    //Get external claims
    var claims = externalUser.Claims.ToList();

    ... additional identity handling and signin on B.
var result = await HttpContext.AuthenticateAsync(IdentityServerConstants.ExternalCookieAuthenticationScheme);