Duplicate accounts from Google and Apple sign-in? Link them
Short answer: Customers end up with two or three accounts when your app treats "Sign in with Google", "Sign in with Apple" and email-and-password as separate front doors. Fix it by storing each sign-in method as a linked identity on one customer record, identified by the provider's issuer and subject ID rather than the email address, and by linking a new method to an existing account only after the customer proves they own that account. Auto-merging on matching email alone is the shortcut that leads to account takeovers.
How duplicates happen
A typical story: a customer creates an account with email and password, orders twice, then months later taps "Continue with Google" on their phone. Your system looks for a Google identity, doesn't find one, and creates a fresh, empty account. Now they can't see their order history, their loyalty points are split and support gets a confused email.
Other common causes:
- Apple's private relay emails. A customer who chooses "Hide My Email" with Apple arrives with a relay address that doesn't match the email on their existing account.
- Changed emails. The customer changed the email on their Google account, or on your site, and the two no longer match.
- Work and personal addresses. They used their work email at checkout and their personal Google account to log in.
The right data model: one customer, many identities
Instead of one login field on the customer record, keep a separate table of identities linked to it. Each row says: this customer can sign in with provider X, whose identifier for them is Y.
What to store as the identifier matters. Google's documentation on verifying ID tokens says to use only the token's sub field as the unique identifier for the user, and its sample code notes that email isn't a good choice because the user can change it. The OpenID Connect specification makes the same point in general: the issuer and subject together are the stable identifier, and other claims such as a preferred username must not be relied on as unique.
So for each social sign-in, store the provider (issuer) plus the sub value. Email is useful information, but it isn't the key.
When is it safe to link automatically?
The tempting rule is "if the Google email matches an existing account's email, log them into that account". It's convenient and sometimes acceptable, but only under conditions.
Google's documentation explains that you can tell whether Google is authoritative for an email address using the email, email_verified and hd fields: a Gmail address, or a verified address with a Google Workspace hosted domain, is one Google vouches for. When the email doesn't end in @gmail.com and hd is absent, Google isn't authoritative, and the documentation recommends a password or other challenge to verify the user. It also warns that email_verified can be true because Google verified the address when the account was created, even though ownership of that third-party email may have changed since.
A safer default for most businesses:
- New social sign-in, no matching email: create a new account.
- New social sign-in, email matches an existing account: don't merge silently. Show "You already have an account with this email. Sign in with your password (or a code we email you) to connect Google."
- After that proof, add the new identity to the existing account.
- Signed-in customers can add or remove sign-in methods from their account settings at any time.
Give customers a way to connect methods themselves
An account settings page with "Ways to sign in" solves most future duplicates:
- List the methods connected: password, Google, Apple, passkey.
- Let customers connect a new one while signed in, which proves ownership of both.
- Let them remove one, but never the last one.
- Email them whenever a sign-in method is added or removed, so a hijack doesn't go unnoticed.
Merging accounts that already exist
If you already have duplicates, merging is a support task with rules:
- Verify ownership of both accounts before merging, for example by signing in to each or by codes sent to both email addresses.
- Decide what moves: orders, addresses, loyalty balance, subscriptions, saved payment references. Payment methods held by your payment provider may need re-adding.
- Keep an audit record of who merged what and when.
- Disable the old account rather than deleting it immediately, in case you need to undo.
For apps with many customers, a self-service merge flow can follow the same steps.
Test the awkward paths
Before release, walk through each case with test accounts: password first then Google; Apple with a hidden email then password; a Google account whose email changed; and removing a method. Check that each ends in one account, that the customer always understands what happened, and that the notification email arrives.
An illustrative example
A hypothetical Bristol meal-kit company found that a noticeable share of support emails came from customers who "lost" their subscription after logging in with Apple on a new phone. Its system created a new account for every new provider. The developers added an identities table keyed on issuer and subject, changed the sign-in flow to ask for an emailed code when a social sign-in matched an existing email, and added a "Ways to sign in" page. Existing duplicates were merged on request after customers confirmed both email addresses.
FAQ
Can I merge automatically when emails match?
Only where the provider is authoritative for that email and you're comfortable with the risk. Asking for one extra proof step is safer and usually only happens once.
What about Apple's relay email?
Treat it like any other email. The customer can connect Apple to their existing account from settings while signed in.
Should I let people sign in with any connected method?
Yes. That's the point of linking: each method opens the same account.
Do passkeys change this?
Passkeys are another identity on the same account. The same rules apply.
If customers keep ending up with duplicate accounts in your app or shop and you'd like the sign-in flow fixed, describe how people log in today.