Add Custom Claims To Auth0 UserInfo Endpoint Response Via Actions
Last Updated:
Overview
Including large data objects directly in the access token exceeds the allowed limit for HTTP headers. Utilizing Auth0 Post-Login Actions to attach data exclusively to the /userinfo endpoint keeps the access token compact and resolves this issue.
Applies To
- Auth0
- Post-Login Actions
- UserInfo Endpoint
- Custom Claims
Solution
How are custom claims added to the UserInfo endpoint using Auth0 Actions?
Configure a Post-Login Action in the Auth0 Dashboard to append custom claims exclusively to the user information response and maintain a compact access token.
- Navigate to Auth0 Dashboard > Actions > Library.
- Select Build Custom.
- Enter a name for the action, select Login / Post Login as the trigger, and select Create.
- Add the custom claims using the
api.idToken.setCustomClaimmethod within the action script. - Select Deploy to save the action.
- Navigate to Auth0 Dashboard > Actions > Flows and select Login.
- Drag the newly created action into the login flow and select Apply.