FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    I want to pass the locale and timezone info to apps via a JWT

    Scheduled Pinned Locked Moved
    Q&A
    jwt timezone locale
    1
    3
    4.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • danD
      dan
      last edited by

      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

      --
      FusionAuth - Auth for devs, built by devs.
      https://fusionauth.io

      1 Reply Last reply Reply Quote 0
      • danD
        dan
        last edited by

        I solved it by myself with a lambda function:

        1. Create a lambda with type JWT populate
        2. 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.

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 0
        • danD
          dan
          last edited by

          There's additional localization and internationalization doc that was written recently here: https://fusionauth.io/docs/v1/tech/core-concepts/localization-and-internationalization/

          --
          FusionAuth - Auth for devs, built by devs.
          https://fusionauth.io

          1 Reply Last reply Reply Quote 0
          • First post
            Last post