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

    User registration provider data

    Scheduled Pinned Locked Moved
    Q&A
    registrations provider claims
    2
    4
    3.8k
    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.
    • A
      ashok
      last edited by dan

      Is there a way to know what provider a user has used to register their account? I'm mainly looking that in the (custom) claims but I don't see it in the admin panel either.

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

        I looked around and I think what you are looking for is the user.registrations[x].tokens value.

        From https://fusionauth.io/docs/v1/tech/apis/users#retrieve-a-user

        A map that contains tokens returned from identity providers.
        
        For example, if this user has authenticated using the Facebook Identity Provider, the Facebook access token will be available in this map, keyed by name Facebook. For an OpenID Connect Identity provider, or other generic providers, if a token is stored it will be keyed by the Identity Provider unique Id.
        

        Does that help?

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

        1 Reply Last reply Reply Quote 0
        • A
          ashok
          last edited by

          That's exactly what I ended up using (by adding it as a custom claim in a lambda function)

          function populate(jwt, user, registration) {
            jwt.provider = Object.keys(registration.tokens)[0];
          }
          

          . The only problem is that I don't seem to be able to pass all the tokens and then "map" it out in the backend. Also, I think I already know the answer to this and this may sound dumb, but how can you have multiple tokens? A user with multiple providers? If so, how are they consolidated and combined?

          Lastly, it would have been nice if user.registrations had a providers field.

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

            @ashok glad you solved the problem!

            The only problem is that I don't seem to be able to pass all the tokens and then "map" it out in the backend.

            I'm not sure what you mean here. Are you not seeing all the tokens in the lambda? Or are you not able to put them all in the custom claim?

            Also, I think I already know the answer to this and this may sound dumb, but how can you have multiple tokens? A user with multiple providers? If so, how are they consolidated and combined?

            A token is tied to a registration/application, so someone could login with google to one FusionAuth application and with facebook to another. Unless I'm missing something, I don't believe they are combined.

            Lastly, it would have been nice if user.registrations had a providers field.

            We welcome your feature requests 🙂 . Please file a github issue: https://github.com/fusionauth/fusionauth-issues/issues

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

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