Get Email from IdentityServer 4 using ASPNetIdentity claims-based-identity entity-framework-core identityserver4


Here is my structure.

-Asp.Net c# Application with IdentityServer 4 used to register and authenticate a user.

-Asp.Net C# Web API that serve some services that used Identity4Server to Authorize a user

-Angular 4 application with ocid-client that use the ASP.Net C# Application to authenticate the angular app.

Question : Actually, when I Print the Authenticated User Claims in the Web API application, I do not see the User Email. Is there a way to see it in the claim.

In WEB API application

    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;


In Indentity Server Application

        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 =
6/9/2017 7:33:40 PM

Popular Answer

you need to add value in dbo.AspNetUserClaims (in ASPNetIdentity database) the IdentityServer4 will get value from this table and set into user claims.

6/13/2017 7:21:49 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow