Custom claim not showing in JWT access token

I have a post login action that adds a custom claim to my JWT access token as suggested in the create custom claim docs.

This is my postlogin action:
exports.onExecutePostLogin = async (event, api) => {
api.accessToken.setCustomClaim(‘testclaim’, ‘authenticated’);
api.idToken.setCustomClaim(‘testclaim’, ‘authenticated’);
};

The custom claim is correctly added to the idtoken but not the accesstoken.
I also tested this via the API debugger extension and the claim is still not showing up.

Please help I have been blocked on this for days!

I can confirm the token I am getting is not opaque, the API debugger and jwt. io show the claims.

Hi @matteo1

Welcome to the Auth0 Community!

If you try debugging the access token received through jtw.io do you have the same result? Do you mind posting the debugged token in order to take a look?

Kind Regards,
Nik

Hi Nik, thanks for following up.

I actually figure out the issue, somewhere in your docs it mentions that scopes that contain the auth0 url do not allow adding custom claims to the access token. After setting up a separate API I was able to mint the token with the correct claims.
Thanks again!