Hi @sanjoy.pator,
Welcome to the Auth0 Community!
I understand that you need some help with setting the Organization ID as a custom claim using a Post Login Action.
After reviewing your code snippet and testing this on my side, I managed to get the Organization ID appended to my tokens successfully.
Below is the code snippet I used in my test:
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://my-app.example.com';
if (event.authorization) {
api.accessToken.setCustomClaim(`${namespace}/organizationId`, event.organization.id);
api.accessToken.setCustomClaim(`organizationId`, event.organization.id);
}
};
Please note that custom claims can be appended using namespaced or non-namespaced identifiers.
See the following resources for more details:
- Namespaced Claims - guidelines
- Non-namespaced Claims - guidelines
- Adding custom claims to tokens FAQ
I hope this helps!
Please let me know how this goes for you.
Thanks,
Rueben