User registration provider data



  • 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.



  • 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?



  • 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.



  • @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