Get Email from IdentityServer 4 using ASPNetIdentity

asp.net-identity claims-based-identity entity-framework-core identityserver4

Question

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;

        this.ContactService.UpdateUserProfile(AspnetUserId,profile);
    }

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 =
            {
                IdentityServerConstants.StandardScopes.OpenId,
                IdentityServerConstants.StandardScopes.Profile,
                "TTAPI",
                IdentityServerConstants.StandardScopes.Email
            }
        }
1
0
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.

0
6/13/2017 7:21:49 AM


Related Questions





Related

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