Auth0 Home Blog Docs

Not getting custom claims back in idToken from Rule

rules

#1

Simple mobile app in flutter so using the basic web authentication no Lock sdks. Have a rule below to return simple Test Claim. Right now have scope set to openid profile. Not getting my test Claim back any ideas?

function (user, context, callback) {

if (context.clientID === ‘XXXXXXXXXXXXXXXXXXXXXXX’) {
context.idToken[‘https://XXXXXXXXXXXXX.auth0.com/test’] = “Dude”;

}
callback(null, user, context);
}


#2

For more information this is a user authenticating with a Auth0 app checking the ClintId of the application in context.

Using the PKCE Flow after calling the oauth/token endpoint I get back idToken but no custom claims are in the token body.


#3

:wave: it may be due to the namespace you are using! We cannot use auth0.com , webtask.io and webtask.run as a namespace identifier. Any non-Auth0 HTTP or HTTPS URL can be used.

Try something like :

function (user, context, callback) {
   if (context.clientID === ‘XXXXXXXXXXXXXXXXXXXXXXX’) {
     context.idToken[https://myapp.example.com/ + 'test'] = 'Dude';
   }
  callback(null, user, context);
}

Let me know if that works!