Issue with custom claims

curl --request POST
–header ‘content-type: application/json’
–data ‘{“client_id”:“xxxxx”,“client_secret”:“xxxx”,“audience”:“https://zasacloud/api",“grant_type”:“client_credentials”,“username”:“”,“password”:"xxxx”}’

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’;
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.

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 you should be using Resource Owner Password Grant. Try changing grant_type to password.

I hope it will help you

Thanks it solved the issue.

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