# The roles are not visible in the access token for grant type Client Credentials grant type

**URL:** <https://devforum.okta.com/t/the-roles-are-not-visible-in-the-access-token-for-grant-type-client-credentials-grant-type/26516>\
**Category:** OAuth/OIDC\
**Created:** [January 27, 2024, 4:25am UTC](https://devforum.okta.com/t/the-roles-are-not-visible-in-the-access-token-for-grant-type-client-credentials-grant-type/26516 "2024-01-27T04:25:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![KaushalGupta](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@KaushalGupta](https://devforum.okta.com/u/KaushalGupta)\
**Post date:** [January 27, 2024, 4:25am UTC](https://devforum.okta.com/t/the-roles-are-not-visible-in-the-access-token-for-grant-type-client-credentials-grant-type/26516/1 "2024-01-27T04:25:51Z")

</div>

Hi Community Team,  
I need you help on the below,  
Here is one example: Service A is utilizing the API of Service B, which is protected with @RolesAllowed. The service A consumes the API with the grant\_type client\_credentials access token. However, we are encountering a 403 error as the request is being denied due to the absence of roles in the access token for grant\_type client\_credentials in Okta. Could you please assist me in resolving this issue? Note: The request is being authenticated but is being denied with a 403 error.

Findings:  
Okta supports sending attributes (including group attributes) for tokens associated with actual users. There does not seem to be any way to associate attributes for client\_credentials grant because its not associated with a user. This is a deficiency in Okta Auth server because many other Auth servers (like Keycloak etc) do support this.

is there any workaround to resolve this ?

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 2, 2024, 10:25pm UTC](https://devforum.okta.com/t/the-roles-are-not-visible-in-the-access-token-for-grant-type-client-credentials-grant-type/26516/2 "2024-02-02T22:25:54Z")

</div>

As you saw, user context is required to return information related to users or group membership. If you are completing Client Credentials flow, there is no user in context and therefore our Groups.startsWith etc functions will not work

The best workaround I can think of would be pretty manual, which is to configure an application profile attribute to hold the list of groups associated with the application and pull that list into the token claim. Check out the steps in this guide for using a static allow list to see if it will work for you: [Customize tokens returned from Okta with a static allow list | Okta Developer](https://developer.okta.com/docs/guides/customize-tokens-static/main/#add-a-groups-claim-with-a-static-allow-list)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 2, 2024, 10:27pm UTC](https://devforum.okta.com/t/the-roles-are-not-visible-in-the-access-token-for-grant-type-client-credentials-grant-type/26516/3 "2024-02-02T22:27:38Z")

</div>

Oh, I also found an Okta Idea that seems to match your use case, [Idea #166547](https://ideas.okta.com/app/#/case/166547). I would definitely recommend upvoting it there so our Product team better track interest in this feature enhancement request

---

<div class="post-metadata">

**Author:** ![KaushalGupta](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@KaushalGupta](https://devforum.okta.com/u/KaushalGupta)\
**Post date:** [February 3, 2024, 7:20am UTC](https://devforum.okta.com/t/the-roles-are-not-visible-in-the-access-token-for-grant-type-client-credentials-grant-type/26516/4 "2024-02-03T07:20:24Z")

</div>

Thank you for your reply. I successfully logged into Okta using Google Sign-In and created my account through the same process. Although I have some access with my account, I am unable to reset the password since it was created directly with Gmail.

I am not able to access the thread [Idea #166547](https://ideas.okta.com/app/#/case/166547) and getting an error message showing in attached screenshot.  
My domain: [dev-79632458.okta.com](http://dev-79632458.okta.com)

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/b/bedf7c2005460a4789b179ab1983eaeb1c6673b7.png)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 5, 2024, 4:22pm UTC](https://devforum.okta.com/t/the-roles-are-not-visible-in-the-access-token-for-grant-type-client-credentials-grant-type/26516/5 "2024-02-05T16:22:02Z")

</div>

Are you able to follow the instructions [here](https://support.okta.com/help/s/article/Okta-Ideas-Overview-FAQ?language=en_US) on how to launch Okta Ideas from the Okta Help Center?

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [March 6, 2024, 4:22pm UTC](https://devforum.okta.com/t/the-roles-are-not-visible-in-the-access-token-for-grant-type-client-credentials-grant-type/26516/6 "2024-03-06T16:22:11Z")

</div>

Closed on March 6, 2024, 4:22pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
