【发布时间】:2017-06-13 15:21:49
【问题描述】:
这是我的结构。
-Asp.Net c# Application with IdentityServer 4 用于注册和验证用户。
-Asp.Net C# Web API,提供一些使用 Identity4Server 授权用户的服务
-带有 ocid-client 的 Angular 4 应用程序,使用 ASP.Net C# 应用程序对 Angular 应用程序进行身份验证。
问题: 实际上,当我在 Web API 应用程序中打印经过身份验证的用户声明时,我看不到用户电子邮件。有没有办法在索赔中看到它。
在 WEB API 应用程序中
if (User.Identity.IsAuthenticated)
{
var claims = User.Claims.ToList();
//Would like to see the User Email Informations
var AspnetUserId = User.Claims.FirstOrDefault(p => p.Type == "sub").Value;
this.ContactService.UpdateUserProfile(AspnetUserId,profile);
}
在 Indentity Server 应用程序中
new Client
{
ClientId = "tgc",
ClientName = "Tag Twee Client Angular",
AllowedGrantTypes = GrantTypes.Implicit,
RequireConsent = false,
AllowAccessTokensViaBrowser = true,
RedirectUris = { "http://localhost:5002/login" },
PostLogoutRedirectUris = { "http://localhost:5002/logout" },
AllowedCorsOrigins = { "http://localhost:5002" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"TTAPI",
IdentityServerConstants.StandardScopes.Email
}
}
【问题讨论】:
标签: asp.net-identity entity-framework-core claims-based-identity identityserver4