How to add groups to access_token? Skip to main content
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Sven SchmidtSven Schmidt 

How to add groups to access_token?


I'm using an Okta app to authenticate via OpenID Connect.

The client allows to call into a web api endpoint, which should have
access control based on groups the authenticated user belongs to (like admin, client, ...).
The trouble is that cannot figure out how to get to the groups from the authentication token.
Currently, I send a request to http://octa.../oauth2/v1/userinfo and extract the groups from the
claims. Is that an acceptable way to do so? Is there a way to avoid that additional request?

Thank you and kind regards,

Jerrell GaryJerrell Gary (Okta, Inc.)
1) If you are trying to use an AD group, which is not supported currently, only Okta group will show up in scope of group claim

2)You will need OIDC APP->SignOn Tab->Groups claim groups Regex .*
User-added image

3) If you use implicit flow, require access_token alone it will also contains groups.
attached the screenshot of request body and header, showing you to user primary auth restAPI to generate sessionToken POST {{url}}/api/v1/authn with request body[username/password]
which will generate you one time use session Token to access the end point of OIDC. If the session expires or the user logs out of Okta after using the token, they will not be able to reuse the same session token to get a new session cookie.

User-added imageUser-added image

4)After you get the sessionToken, use below URL in your script which generate you an access_token.

5)Pass access token as bear token to endpoint {{url}}/oauth2/v1/userinfo, here is how request body and request header looks like, now you see the group in scope of claim.
User-added imageUser-added image
John GronbergJohn Gronberg (Okta, Inc.)
Sven, If you are interested in accessing non-Okta groups (like Active Directory groups), we do support those as part of our API Access Management product. Details on doing this are included in our 2017.20 Release Notes: , using the 'getFilteredGroups' expression as part of a custom claim. This functionality is not available in our basic OpenID Connect solution.