account linking google > username password (signups / registration) #1781

Closed
opened 2026-03-13 09:02:45 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @MariuzM on GitHub (Aug 25, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I have 2 use cases for this:

  1. When user signups with username and password and then uses google login all that is working
  2. When user uses google login and then tries to register with username and password that does not work

Current vs. Expected behavior

How can i link accounts when first does google login / signup and then tries to do username and password signup?

Vise versa it does work but not Google First > Username Password Second (Signup / Registration)

What version of Better Auth are you using?

1.3.7

System info

System:
    OS: macOS 15.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 25.71 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Brave Browser: 139.1.81.136
    Chrome: 138.0.7204.49
    Safari: 18.6

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @MariuzM on GitHub (Aug 25, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I have 2 use cases for this: 1. When user signups with username and password and then uses google login all that is working 2. When user uses google login and then tries to register with username and password that does not work ### Current vs. Expected behavior How can i link accounts when first does google login / signup and then tries to do username and password signup? Vise versa it does work but not Google First > Username Password Second (Signup / Registration) ### What version of Better Auth are you using? 1.3.7 ### System info ```bash System: OS: macOS 15.6.1 CPU: (10) arm64 Apple M1 Max Memory: 25.71 GB / 64.00 GB Shell: 5.9 - /bin/zsh Browsers: Brave Browser: 139.1.81.136 Chrome: 138.0.7204.49 Safari: 18.6 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the social-provider label 2026-03-13 09:02:45 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 25, 2025):

Hi @MariuzM! I'm Dosu and I’m helping the better-auth team.

Better Auth v1.3.7 does not support linking a username/password credential to an account that was created via Google OAuth (Google-first, then username/password) out of the box. The username/password plugin only creates a new user if the username is not taken, and does not merge or link with an existing Google-authenticated account during signup or update. This is why the reverse flow (username/password first, then Google) works, but Google-first does not—there’s no logic to attach a credential to an existing OAuth account in the username/password plugin or its hooks source.

To enable Google-first then username/password linking, you’d need to implement custom logic: for example, a manual endpoint or plugin extension that detects an existing user (by email or other identifier) and attaches the credential provider to that account instead of creating a new one. The modular design of Better Auth means this is possible, but not currently supported or documented as a standard flow source.

If you want to pursue this, look into customizing the signup/update hooks or extending the adapter logic to support bidirectional linking. There are no official guides or tickets for this workflow yet.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 25, 2025): <!-- Greeting --> Hi @MariuzM! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> Better Auth v1.3.7 does not support linking a username/password credential to an account that was created via Google OAuth (Google-first, then username/password) out of the box. The username/password plugin only creates a new user if the username is not taken, and does not merge or link with an existing Google-authenticated account during signup or update. This is why the reverse flow (username/password first, then Google) works, but Google-first does not—there’s no logic to attach a credential to an existing OAuth account in the username/password plugin or its hooks [source](https://github.com/better-auth/better-auth/blob/8c23eb07396478a51b4dc7de669c010cdadc5479/packages/better-auth/src/plugins/username/index.ts). To enable Google-first then username/password linking, you’d need to implement custom logic: for example, a manual endpoint or plugin extension that detects an existing user (by email or other identifier) and attaches the credential provider to that account instead of creating a new one. The modular design of Better Auth means this is possible, but not currently supported or documented as a standard flow [source](https://better-auth.com/docs/plugins/username). If you want to pursue this, look into customizing the signup/update hooks or extending the adapter logic to support bidirectional linking. There are no official guides or tickets for this workflow yet. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/e20f5997-24cc-4998-9b85-eb6f5bc05f06?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e20f5997-24cc-4998-9b85-eb6f5bc05f06?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e20f5997-24cc-4998-9b85-eb6f5bc05f06?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e20f5997-24cc-4998-9b85-eb6f5bc05f06?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e20f5997-24cc-4998-9b85-eb6f5bc05f06?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e20f5997-24cc-4998-9b85-eb6f5bc05f06?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e20f5997-24cc-4998-9b85-eb6f5bc05f06?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4218)
Author
Owner

@pushkarsingh32 commented on GitHub (Oct 18, 2025):

So what are you saying is if I sign up using google, and then after sometime try to login using that google email id directly using email password option by making password through password reset option. it will not work? please confirm @dosu

@pushkarsingh32 commented on GitHub (Oct 18, 2025): So what are you saying is if I sign up using google, and then after sometime try to login using that google email id directly using email password option by making password through password reset option. it will not work? please confirm @dosu
Author
Owner

@Bekacru commented on GitHub (Nov 24, 2025):

You should use reset password flow instead

@Bekacru commented on GitHub (Nov 24, 2025): You should use reset password flow instead
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1781