wso2wso2-identity-server

Adding Extra Fields to Access Token in WSO2 Identity Server


I am working with WSO2 Identity Server and I need to add additional fields to the access token returned from the /oauth2/token endpoint. The current structure of the access token is as follows:

{
  "sub": "XXXXXX-XXXXX-XXXX-XXX-XXXXXXXXXX",
  "aut": "APPLICATION_USER",
  "aud": "QVwR39k12Fqu",
  "nbf": 1234581515,
  "azp": "WVwR39k12Fqu_YTGKJHNlk",
  "scope": "default",
  "iss": "https://localhost:9443/oauth2/token",
  "exp": 153566545,
  "iat": 55585552,
  "jti": "89852_defsdfcsddf",
  "client_id": "Ussswtttt"
}

I would like to add extra fields from user information to this token. Is there a configuration or extension point in WSO2 Identity Server that allows me to include additional information in the access token? If so, could you provide guidance on how to achieve this?

Additional Context: WSO2 Identity Server version: 6.0.0


Solution

  • You can get this done as follows:

    1. Hope you have a local claim for the user attribute.

    2. Add an OIDC claim mapping for your local claim

    enter image description here

    1. Go to the created oauth/oidc based service provider -> Claim Configurations-> add the local claim you want in the JWT as a Requested Claims

    2. Go to OIDC Scopes section of - > List. Select openid scope. Click Add Claims and give the OIDC claim you created in step 2

    Now try the token retrieval with scope=openid. If the user has a value to the particular claim, you can get it in the JWT access token and ID token