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

    How to prevent storing first/last name in FusionAuth user data from social login?

    Scheduled Pinned Locked Moved Solved
    Frequently Asked Questions (FAQ)
    social-login lambda user-data privacy reconcile
    1
    2
    68
    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.
    • F
      FASupportBot
      last edited by

      When using FusionAuth's hosted login pages with social login (e.g., Google), personal information like first name, last name, and full name are automatically stored in the FusionAuth user object.

      We want to store only the email address in FusionAuth and move all other personal information to our own profile service. What is the best approach to prevent or remove this data from FusionAuth while still using social login and registration?

      Is there a way to prevent FusionAuth from storing this information in the first place, or do we need to clear it after user creation?

      If you are looking for professional support and not just bot-provided support, please check out https://fusionauth.io/pricing and pick a plan that fits your needs.

      1 Reply Last reply Reply Quote 0
      • F
        FASupportBot
        last edited by

        FusionAuth does not have a direct passthrough option to prevent storing user data from social login providers. However, there are several approaches to handle this:

        Option 1: Use a Reconcile Lambda (Recommended for Social Login)

        For social login providers like Google, you can use a reconcile lambda to intentionally overwrite the user data with placeholder values before it's permanently stored:

        function reconcile(user, registration, idToken) {
          // The idToken is the response from the tokeninfo endpoint
          // https://developers.google.com/identity/sign-in/web/backend-auth#calling-the-tokeninfo-endpoint
          
          user.firstName = "Purposely not set";
          user.lastName = "Purposely not set";
          user.fullName = "Purposely not set";
          user.imageUrl = "http://www.notset.com";
        }
        

        This ensures that personal data from the social provider is replaced immediately during the reconciliation process.

        Option 2: Minimal Registration Form

        For new user registrations (non-social), configure your registration form to collect only email and password, avoiding the collection of first/last name entirely.

        Option 3: Use Webhooks to Clear Data

        Implement a user.create.complete webhook that listens for new user creation events, then use the FusionAuth User API to clear the personal data fields and move them to your profile service. Note that this approach means user data will briefly exist in FusionAuth before being cleared.

        Option 4: Lambda with External Fetch (Advanced)

        You could use lambdas with fetch calls to move data to your profile service and set FusionAuth fields to null. However, this introduces latency due to network calls during authentication flows.

        For Existing Users

        If you already have users with stored data, use the User API to programmatically clear the values for all existing users.

        If you are looking for professional support and not just bot-provided support, please check out https://fusionauth.io/pricing and pick a plan that fits your needs.

        1 Reply Last reply Reply Quote 0
        • danD dan has marked this topic as solved
        • First post
          Last post