How to pass additional user data as user claims collection to MVC client from Identity Server 4.0

Mayuri Barve 1 Reputation point
2021-06-08T12:08:29.35+00:00

I am using Identity Server 4.0 (OAuth2 and OpenID) for authenticating user and implementing SSO feature in our application. I have used IDS Quickstart application to create MVC client app. MVC client application user is getting authenticated against external service. Meaning user details/credentials are not stored in IDS database hence there is no any IdentityUser used during authentication flow. to store user credentials I have created a ViewModel and passing that to the AccountsControllers Login action. IDS sends the credentials to external service(Web service) to authenticate user. The service authenticates user and returns two values in response, Auth code and user attributes collection.

Once I get response, I want to add the additional attributes to user claims collection to pass it to MVC client where I can display all those attributes about user on Secure page. I have created a ProfileService class and I am adding all the attributes to Context.IssuedClaims collection in GetProfileDataAsync method but still I am not getting those claims in client application. It only returns standard claims like sub email, username etc in User.Claims collection.
Can anyone suggest what I am missing here or how I can implement it so that I will get all user attributes to MVC client as user claims.
I have already spent lot of time on this, tried lot of options and referred lot of google SO etc links but no luck

If anyone can suggest a correct way of doing it ASAP that will be great!

Thanks.

Microsoft Identity Manager
Microsoft Identity Manager
A family of Microsoft products that manage a user's digital identity using identity synchronization, certificate management, and user provisioning.
706 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.