# Add roles in payload of client credentials

**URL:** <https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113>\
**Category:** Get Help\
**Tags:** client-credentials-g, machine-to-machine\
**Created:** [July 30, 2021, 6:51am UTC](https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113 "2021-07-30T06:51:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![abelose90](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/abelose90/32/30850_2.png) [@abelose90](https://community.auth0.com/u/abelose90)\
**Post date:** [July 30, 2021, 6:51am UTC](https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113/1 "2021-07-30T06:51:47Z")

</div>

Hi, my use case is quite simple. I am running postman tests and the apis need the jwt token. Currently I am passing the bearer token manually, which I would like to automate.  
I payload of my bearer token I am adding Roles with the help of rules.  
I am across client-credentials which could be one of the option to get bearer token but I am not able to add roles in payload with the help of hooks.  
Am I missing here anything?  
Is using client-credentials for my use case is right option?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 30, 2021, 5:14pm UTC](https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113/3 "2021-07-30T17:14:03Z")

</div>

Hi @abelose90,

Welcome to the Auth0 Community!

Client credentials is for userless, machine to machine authorization.

Rules only run for user based flows.

I don’t fully understand your use case. Are you asking how to request a user’s access token via postman?

---

<div class="post-metadata">

**Author:** ![abelose90](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/abelose90/32/30850_2.png) [@abelose90](https://community.auth0.com/u/abelose90)\
**Post date:** [July 30, 2021, 5:50pm UTC](https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113/4 "2021-07-30T17:50:25Z")

</div>

Hi Dan, thanks for clarification.

In current set up I am running a rule. On successful user login rule add roles assigned to the user in the access token.

My use case is, I am running some postman test cases. The apis for which I am running those test cases requires bearer token. These bearer token should have specific role in access token’s payload. Currently I am doing the manual process of copying the bearer token by logging into application inspect the page and going to network tab, copying the access token and running those tests.  
I would like to automate the process of fetching the access token with appropriate roles.

Can you please tell me,

1. Is it possible to request user’s token via postman?

2. I was also exploring the client credentials option. I am able to obtain access token. I am wondering if I could add roles in access token using client credentials. Because without roles in the access token I cannot access any api.

Let me know if you need anymore details.

Thanks

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 2, 2021, 3:51pm UTC](https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113/5 "2021-08-02T15:51:49Z")

</div>

Thanks for elaborating. I think I understand what you are trying to accomplish.

> [@abelose90](#):
>
> Is it possible to request user’s token via postman?

Yes, the easiest way to get a user’s token in postman is to use the [resource owner password grant](https://auth0.com/docs/flows/call-your-api-using-resource-owner-password-flow). This grant allows you to exchange a username/password directly for a token. It is important to understand that this grant type leaves your application open to some added security considerations, but that shouldn’t be a problem if you are only using it during testing/development. Just be sure to turn it off once you are finished.

> [@abelose90](#):
>
> I was also exploring the client credentials option. I am able to obtain access token. I am wondering if I could add roles in access token using client credentials. Because without roles in the access token I cannot access any api.

This type of flow does not include roles, as there is no user involved.

---

<div class="post-metadata">

**Author:** ![abelose90](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/abelose90/32/30850_2.png) [@abelose90](https://community.auth0.com/u/abelose90)\
**Post date:** [August 3, 2021, 8:32am UTC](https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113/6 "2021-08-03T08:32:40Z")

</div>

Thanks @dan.woda .

I went through the documentation for resource owner password grant, this is applicable for **Regular Web Apps**. And one thing I missed out informing that I am using SPA application type.  
Is there anyway for getting access token for SPA application type with same use case?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 3, 2021, 3:17pm UTC](https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113/7 "2021-08-03T15:17:33Z")

</div>

You can get the access token in a SPA type application using this same method. We don’t recommend it for production, like I mentioned, but you shouldn’t have an issue using it to test gettings some tokens in postman.

This shows exactly how to make the call: [Call Your API Using Resource Owner Password Flow](https://auth0.com/docs/flows/call-your-api-using-resource-owner-password-flow#request-tokens)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 23, 2021, 4:49pm UTC](https://community.auth0.com/t/add-roles-in-payload-of-client-credentials/67113/8 "2021-08-23T16:49:47Z")

</div>

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