# Issue with custom claims

**URL:** <https://community.auth0.com/t/issue-with-custom-claims/121816>\
**Category:** Get Help\
**Tags:** identifier-first, login-experience\
**Created:** [November 28, 2023, 3:36pm UTC](https://community.auth0.com/t/issue-with-custom-claims/121816 "2023-11-28T15:36:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zasa](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@zasa](https://community.auth0.com/u/zasa)\
**Post date:** [November 28, 2023, 3:36pm UTC](https://community.auth0.com/t/issue-with-custom-claims/121816/1 "2023-11-28T15:36:50Z")

</div>

curl --request POST   
–url [https://xxxxx.us.auth0.com/oauth/token](https://xxxxx.us.auth0.com/oauth/token)   
–header ‘content-type: application/json’   
–data ‘{“client\_id”:“xxxxx”,“client\_secret”:“xxxx”,“audience”:“[https://zasacloud/api",“grant\_type”:“client\_credentials”,“username”:“test@tst.com”,“password”:"xxxx](https://zasacloud/api%22,%22grant_type%22:%22client_credentials%22,%22username%22:%22test@tst.com%22,%22password%22:%22xxxx)”}’

I am sending above request to get the token, I am getting the token but not getting custom claims. Below is the code defined for passing custom clais in token

exports.onExecutePostLogin = async (event, api) =\> {  
// This rule adds the authenticated user’s email address to the access token.  
if (event.authorization) {  
var namespace = ‘[http://test](http://test)’;  
api.accessToken.setCustomClaim(`${namespace}/email`, event.user.email)  
api.idToken.setCustomClaim(`${namespace}/email`, event.user.email)  
api.idToken.setCustomClaim(`${namespace}/preferred_contact`, “sms”);  
api.accessToken.setCustomClaim(`${namespace}/preferred_contact`, “sms”);  
}  
};

I am clueless on what is wrong with above steps. Also when I test the action, I see values, but not getting in return with aPI call.

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [November 28, 2023, 4:45pm UTC](https://community.auth0.com/t/issue-with-custom-claims/121816/2 "2023-11-28T16:45:55Z")

</div>

Hi @zasa

Welcome to the Auth0 Community!

Thank you for posting your question, I think that you are using the incorrect grant type, instead of the [Client Credentials Grant](https://auth0.com/docs/flows/client-credentials-flow) you should be using [Resource Owner Password Grant](https://auth0.com/docs/flows/resource-owner-password-flow). Try changing grant\_type to `password`.

I hope it will help you  
Thanks  
Dawid

---

<div class="post-metadata">

**Author:** ![zasa](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@zasa](https://community.auth0.com/u/zasa)\
**Post date:** [November 29, 2023, 6:07am UTC](https://community.auth0.com/t/issue-with-custom-claims/121816/3 "2023-11-29T06:07:25Z")

</div>

Thanks it solved the issue.

---

<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:** [December 13, 2023, 6:07am UTC](https://community.auth0.com/t/issue-with-custom-claims/121816/4 "2023-12-13T06:07:37Z")

</div>

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