I have an implementation of identity server. One of the things I recently found out is that if I have a user claim (ex. picture) that is mapped to an API / API Scope (openid-api-scope), even if it is associated with an identity scope, the claim, is removed as an identity scope.
Why do you need the same user claim in both access token and userinfo endpoint?
As far as I know, access_token is for API / external system consumption while my end client will use the identity information from userinfo for client consumption. So to avoid getting a large identity token, It would be good to have the information available through the back channel call userinfo. I know the alternative is to set the AlwaysIncludeUserClaimsInIdToken to true.
Goal: Get the same user claim in access token and response from UserInfo endpoint without needing to AlwaysIncludeUserClaimsInIdToken = true
Example
please take note that picture here is just an example to illustrate the point and is not exactly the same user claim I intend to use this for.
Original Setup (default)
- Identity Resource: openid
- Identity Claim: picture
- Client: AlwaysIncludeUserClaimsInIdToken: false
Client Scope: openid
Returns:
- access token (with no picture claim)
- id_token (no picture claim)
- using access token against UserInfo : returns claims including picture)
Additional Setup
(assume that resource, scope and scope claim are associated)
- API Resource : openid-api
- API Scope : openid-api-scope
- API Scope Claim : picture
Returns:
- access token (with picture claim)
- id_token (no picture claim)
- using access token against UserInfo : does not return claims picture claim
Workaround
- Client: AlwaysIncludeUserClaimsInIdToken: true
Returns:
- access token (with picture claim)
- id_token (with picture claim)
- using access token against UserInfo : does not return claims picture claim