I want to pass the locale and timezone info to apps via a JWT
-
If we want to use FusionAuth to authenticate an user to a third party application, we want that the third party application uses the language and the timezone from the FusionAuth user settings. If I connect an external identity provider with FusionAuth, the claim "locale" (defined in openid connect: https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims) will be stored in FusionAuth, but FusionAuth doesn't send the claim while authentication about SSO.
Moved over from https://github.com/FusionAuth/fusionauth-issues/issues/401
-
I solved it by myself with a lambda function:
- Create a lambda with type JWT populate
- Add the following code:
function populate(jwt, user, registration) { preferredLanguages = user.preferredLanguages; if(preferredLanguages === null || preferredLanguages === undefined || preferredLanguages.length === 0) { return; } // set first preferred language to jwt jwt.locale = user.preferredLanguages[0]; // set zoneinfo to jwt jwt.zoneinfo = user.timezone; }
Finally, in your application settings click on JWT and set your lambda function to Access token populate lambda.
-
There's additional localization and internationalization doc that was written recently here: https://fusionauth.io/docs/v1/tech/core-concepts/localization-and-internationalization/