Inserting groups into id token

Is it possible to list in id_token all groups that user is assigned to? I’ve tried using identity.getAttributes([“groups”]) in OAuth2 Access Token Modification Script but it didn’t work.
Thanks for help in advance!

Hi @tapselo

If you are talking about placing this claim into an id token, you will want to be using an OIDC Claims script, not an OAuth2 token modification script. You can then import the com.sun.identity.idm.IdType class in your script and use identity.getMemberships(IdType.GROUP) to return all of the groups associated with the authenticated user.

Hope this helps!

1 Like