login_hint for social linking (linkSocialAccount) #2207

Open
opened 2026-03-13 09:34:41 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @CarrettaRiccardo on GitHub (Oct 26, 2025).

Is this suited for github?

  • Yes, this is suited for github

Currently, I can find no solution to provide custom parameters to Google account linking.

Fore reference, using Firebase you can add parameters to Google sign in, for example hinting for a specific email only:

import {
    CustomParameters,
    GoogleAuthProvider,
    linkWithPopup,
    signInWithPopup,
    User
} from "firebase/auth";

// ...
    const provider = new GoogleAuthProvider();
    const customParams: CustomParameters = {
        prompt: "select_account",
    };

    // Add login_hint only for link mode
    customParams.login_hint = currentUser.email;
    provider.setCustomParameters(customParams);

    result = await linkWithPopup(currentUser, provider);
// ...

Describe the solution you'd like

Currently, search and params properties can be passed to the auth instance (client or server side):

const { redirect, url } = await auth.api.linkSocialAccount({
    body: {
        provider: input.provider,
        idToken: input.id_token,
    },
    // add login_hint
    query: {
        login_hint: ctx.user.email,
    },
    // or
    params: {
        login_hint: ctx.user.email,
    },
    headers: ctx.headers,
});

But neither query nor params seem to append login_hint to the url's query params.
I can only do it manually.

Describe alternatives you've considered

authClient / auth's query or params options shall be appended to the url's search parameters automatically

Additional context

No response

Originally created by @CarrettaRiccardo on GitHub (Oct 26, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Currently, I can find no solution to provide `custom parameters` to Google account linking. Fore reference, using Firebase you can add parameters to Google sign in, for example hinting for a specific email only: ```ts import { CustomParameters, GoogleAuthProvider, linkWithPopup, signInWithPopup, User } from "firebase/auth"; // ... const provider = new GoogleAuthProvider(); const customParams: CustomParameters = { prompt: "select_account", }; // Add login_hint only for link mode customParams.login_hint = currentUser.email; provider.setCustomParameters(customParams); result = await linkWithPopup(currentUser, provider); // ... ``` ### Describe the solution you'd like Currently, search and params properties can be passed to the auth instance (client or server side): ```ts const { redirect, url } = await auth.api.linkSocialAccount({ body: { provider: input.provider, idToken: input.id_token, }, // add login_hint query: { login_hint: ctx.user.email, }, // or params: { login_hint: ctx.user.email, }, headers: ctx.headers, }); ``` But neither `query` nor `params` seem to append `login_hint` to the url's query params. I can only do it manually. ### Describe alternatives you've considered authClient / auth's `query` or `params` options shall be appended to the url's search parameters automatically ### Additional context _No response_
GiteaMirror added the enhancement label 2026-03-13 09:34:41 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 26, 2025):

Better Auth does not currently append custom parameters like login_hint from query or params to the Google social linking authorization URL automatically. The backend only threads explicit parameters (such as scopes, state, and redirect URI) to the provider, and while the Google provider supports a login_hint parameter, it must be passed directly through its API, not via generic query or params options from the client call see code.

There are open feature requests to allow dynamic provider options (like login_hint, prompt, etc.) when linking social accounts issue #2351 and to expose an additionalParams option for more flexible OAuth flows issue #5441. For now, the workaround is to manually append the desired parameters to the returned URL before redirecting the user.

If you need to set login_hint, you can intercept the URL returned by linkSocialAccount, append the parameter manually, and then redirect the user. Tracking the above issues is recommended for future updates on this feature.

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 (Oct 26, 2025): <!-- Answer --> Better Auth does not currently append custom parameters like `login_hint` from `query` or `params` to the Google social linking authorization URL automatically. The backend only threads explicit parameters (such as scopes, state, and redirect URI) to the provider, and while the Google provider supports a `login_hint` parameter, it must be passed directly through its API, not via generic query or params options from the client call [see code](https://github.com/better-auth/better-auth/blob/56cd2083bf18d5bf3f737fcb564ef69f3b864e7b/packages/core/src/social-providers/google.ts). There are open feature requests to allow dynamic provider options (like `login_hint`, `prompt`, etc.) when linking social accounts [issue #2351](https://github.com/better-auth/better-auth/issues/2351) and to expose an `additionalParams` option for more flexible OAuth flows [issue #5441](https://github.com/better-auth/better-auth/issues/5441). For now, the workaround is to manually append the desired parameters to the returned URL before redirecting the user. If you need to set `login_hint`, you can intercept the URL returned by `linkSocialAccount`, append the parameter manually, and then redirect the user. Tracking the above issues is recommended for future updates on this feature. <!-- 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/533d4745-6305-4a5c-ab99-f5389d7d19bd?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/533d4745-6305-4a5c-ab99-f5389d7d19bd?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/533d4745-6305-4a5c-ab99-f5389d7d19bd?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/533d4745-6305-4a5c-ab99-f5389d7d19bd?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/533d4745-6305-4a5c-ab99-f5389d7d19bd?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/533d4745-6305-4a5c-ab99-f5389d7d19bd?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/533d4745-6305-4a5c-ab99-f5389d7d19bd?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/5592)
Author
Owner

@CarrettaRiccardo commented on GitHub (Oct 26, 2025):

After further investigation, apparently this is possible by using method auth.api.signInSocial:

const result = await auth.api.signInSocial({
    body: {
        provider: "google",
        loginHint: ctx.user?.email,
        requestSignUp: true,
    },
    headers: ctx.headers,
});

Unclear why this is present in signInSocial but not on linkSocialAccount, which is correct use-case for this.

@CarrettaRiccardo commented on GitHub (Oct 26, 2025): After further investigation, apparently this is possible by using method `auth.api.signInSocial`: ```ts const result = await auth.api.signInSocial({ body: { provider: "google", loginHint: ctx.user?.email, requestSignUp: true, }, headers: ctx.headers, }); ``` Unclear why this is present in `signInSocial` but not on `linkSocialAccount`, which is correct use-case for this.
Author
Owner

@tmchow commented on GitHub (Dec 29, 2025):

After further investigation, apparently this is possible by using method auth.api.signInSocial:

const result = await auth.api.signInSocial({
body: {
provider: "google",
loginHint: ctx.user?.email,
requestSignUp: true,
},
headers: ctx.headers,
});
Unclear why this is present in signInSocial but not on linkSocialAccount, which is correct use-case for this.

Thanks for this, super helpful workaround.

@tmchow commented on GitHub (Dec 29, 2025): > After further investigation, apparently this is possible by using method `auth.api.signInSocial`: > > const result = await auth.api.signInSocial({ > body: { > provider: "google", > loginHint: ctx.user?.email, > requestSignUp: true, > }, > headers: ctx.headers, > }); > Unclear why this is present in `signInSocial` but not on `linkSocialAccount`, which is correct use-case for this. Thanks for this, super helpful workaround.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2207