Naveen Kumar
Naveen Kumar

Reputation: 11

Identity server3 : User Info endpoint returns null Claims

I am using Authorization Code flow and I am trying to get the user information using user info endpoint, but I am not getting claims. I've enabled IncludeInIdToken for some claims like name profile email and when decode Idtoken I was not able to see the above claims. I've tried by debugging the method GetProfileDataAsync, here I found the "Name" property coming null, since I am using the AD group I need this Name property here. I tried to save "Name" into global variable in LocalLoginAsync method and used the same in GetProfileDataAsync method. Now I have added claims to the TaskResult, but I am getting count '0' in the response

When I request for tokens by using code I am able to see the following result in Claims

Claims

and I am not able to see those claims in IdToken, Id_token

Next, time when request using user info endpoint by using access token I am not getting any Claim except "sub" or no Name property.

How can I get Claim with User Info endpoint response

Upvotes: 0

Views: 548

Answers (2)

Lutando
Lutando

Reputation: 5010

I am assuming that you are requesting the profile scope in your request. If this is true then username is not a valid scope and does not form part of the list of standard claims for this scope. you should rename your claim to either nickname or preferred_username

Upvotes: 0

Naveen Kumar
Naveen Kumar

Reputation: 11

I've tried by debugging the code and found the issue, since I am doing the mistake like

return Task.FormResult(identity.Claims.where(x=>context.RequestedClaimTypes.Contains(x.Types)));

instead of doing

context.IssuedClaims = identity.Claims.where(x=>context.RequestedClaimTypes.Contains(x.Types)); return Task.FromResult(0);

But still I am getting the username(Name) property null with user info endpoint..,

Upvotes: 0

Related Questions