[GH-ISSUE #6582] Google callbackURL not triggered after full login flow (no active session) #27883

Open
opened 2026-04-17 19:08:45 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @ilaloov on GitHub (Dec 7, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6582

Originally assigned to: @Paola3stefania on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Use a device that has access to Google account but no session in the browser
  2. Tap Continue with Google
  3. Browser opens
  4. Enter email and password
  5. User is redirected to 2FA
Image
  1. Confirm 2FA
  2. After confirming, the user is returned to the app and code execution continues, but there is neither deep linking nor a session created

Current vs. Expected behavior

The authentication flow works as expected when the user is already signed in the browser (they must only choose an account). However, when there is no active Google session in the browser (they must enter email and password), the OAuth completes but the app never receives the deep link callback. The code continues executing from await authClient.signIn.social.

What version of Better Auth are you using?

1.4.5

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:29:54 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8122",
    "release": "24.6.0",
    "cpuCount": 8,
    "cpuModel": "Apple M3",
    "totalMemory": "24.00 GB",
    "freeMemory": "0.46 GB"
  },
  "node": {
    "version": "v22.13.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.4.2"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "19.1.0"
    }
  ],
  "databases": [
    {
      "name": "drizzle",
      "version": "^0.44.7"
    }
  ],
  "betterAuth": {
    "version": "^1.4.5",
    "config": null
  }
}

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

Client

Auth config (if applicable)

import { betterAuth } from 'better-auth';

export const auth = betterAuth({
  plugins: [expo()],
  socialProviders: {
    google: {
      clientId: '',
      clientSecret: '',
      prompt: 'select_account',
    },
  },
  trustedOrigins: [],
});

Additional context

The project is configured as per Expo Integration and this.

Originally created by @ilaloov on GitHub (Dec 7, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6582 Originally assigned to: @Paola3stefania on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Use a device that has access to Google account but no session in the browser 2. Tap **Continue with Google** 3. Browser opens 4. Enter email and password 5. User is redirected to 2FA <img width="400" height="400" alt="Image" src="https://github.com/user-attachments/assets/d663e4ce-bc2a-4d2e-ac7b-ca01da3ef7db" /> 6. Confirm 2FA 7. After confirming, the user is returned to the app and code execution continues, but there is neither deep linking nor a session created ### Current vs. Expected behavior The authentication flow works as expected when the user is already signed in the browser (they must only choose an account). However, when there is no active Google session in the browser (they must enter email and password), the OAuth completes but the app never receives the deep link callback. The code continues executing from `await authClient.signIn.social`. ### What version of Better Auth are you using? 1.4.5 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:29:54 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8122", "release": "24.6.0", "cpuCount": 8, "cpuModel": "Apple M3", "totalMemory": "24.00 GB", "freeMemory": "0.46 GB" }, "node": { "version": "v22.13.0", "env": "development" }, "packageManager": { "name": "npm", "version": "11.4.2" }, "frameworks": [ { "name": "react", "version": "19.1.0" } ], "databases": [ { "name": "drizzle", "version": "^0.44.7" } ], "betterAuth": { "version": "^1.4.5", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ``` import { betterAuth } from 'better-auth'; export const auth = betterAuth({ plugins: [expo()], socialProviders: { google: { clientId: '', clientSecret: '', prompt: 'select_account', }, }, trustedOrigins: [], }); ``` ### Additional context The project is configured as per [Expo Integration](https://www.better-auth.com/docs/integrations/expo) and [this](https://www.better-auth.com/docs/authentication/google).
GiteaMirror added the platformoauthbug labels 2026-04-17 19:08:46 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 7, 2025):

tag @better-auth-agent if you would like an answer from the Agent

Could you please confirm if you've already tried ensuring that your Expo configuration is fully aligned with our documentation for Google authentication, especially regarding the deep linking setup in your Expo app? This information will help us better diagnose why the callback isn't being triggered. tag @better-auth-agent if you would like an answer from the Agent

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3621885152 --> @better-auth-agent[bot] commented on GitHub (Dec 7, 2025): tag @better-auth-agent if you would like an answer from the Agent Could you please confirm if you've already tried ensuring that your Expo configuration is fully aligned with our documentation for Google authentication, especially regarding the deep linking setup in your Expo app? This information will help us better diagnose why the callback isn't being triggered. tag @better-auth-agent if you would like an answer from the Agent _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Dec 7, 2025):

This is a known issue with Better Auth v1.4.5 and Expo, especially after Google 2FA or when there’s no active browser session. The main causes are: (1) a bug where the OAuth state cookie uses SameSite=Lax, which breaks state validation after POST redirects (fixed in newer versions), and (2) Expo/Android browser quirks where the login browser closes during 2FA, so the deep link callback never fires and the session isn’t created details expo/2FA browser issue.

Here’s what you can do:

  1. Upgrade to the latest better-auth and @better-auth/expo if possible. This resolves the cookie/state bug and improves Expo compatibility upgrade advice.
  2. If you must stay on v1.4.5, set the state cookie to SameSite=None and Secure=true in your Better Auth config:
    advanced: {
      cookies: {
        state: {
          attributes: {
            sameSite: "none",
            secure: true,
          }
        }
      }
    }
    
  3. After await authClient.signIn.social(...), immediately call await authClient.getSession() to force a session refresh. This is a reliable workaround for session not being available after OAuth on Expo/mobile workaround.
  4. Double-check your Google OAuth redirect URI: it must be a public HTTPS URL (not a custom scheme), registered in both Google Cloud Console and your Better Auth config redirect URI docs.
  5. Make sure your Expo app’s scheme (in app.json) matches what’s in your Better Auth server’s trustedOrigins. The backend must append the session cookie to the deep link for the Expo client to pick it up deep link/cookie propagation.
  6. On Android, if the browser closes during 2FA, try passing { showInRecents: true } to WebBrowser.openAuthSessionAsync or prefer Chrome as the browser. This keeps the browser open during 2FA and helps the callback fire 2FA workaround.
  7. Add logging to check if the deep link contains the cookie parameter and if SecureStore is saving it after OAuth callback. If missing, it’s likely a trustedOrigins or backend config issue.

If these steps don’t resolve it, share your Better Auth config, Expo scheme, and a log of the deep link/callback URL after sign-in for more targeted help.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3621888964 --> @dosubot[bot] commented on GitHub (Dec 7, 2025): <!-- Answer --> This is a known issue with Better Auth v1.4.5 and Expo, especially after Google 2FA or when there’s no active browser session. The main causes are: (1) a bug where the OAuth state cookie uses `SameSite=Lax`, which breaks state validation after POST redirects (fixed in newer versions), and (2) Expo/Android browser quirks where the login browser closes during 2FA, so the deep link callback never fires and the session isn’t created [details](https://github.com/better-auth/better-auth/issues/6483) [expo/2FA browser issue](https://github.com/better-auth/better-auth/issues/1447). Here’s what you can do: 1. **Upgrade** to the latest `better-auth` and `@better-auth/expo` if possible. This resolves the cookie/state bug and improves Expo compatibility [upgrade advice](https://github.com/better-auth/better-auth/issues/5034). 2. If you must stay on v1.4.5, set the state cookie to `SameSite=None` and `Secure=true` in your Better Auth config: ```ts advanced: { cookies: { state: { attributes: { sameSite: "none", secure: true, } } } } ``` 3. **After** `await authClient.signIn.social(...)`, immediately call `await authClient.getSession()` to force a session refresh. This is a reliable workaround for session not being available after OAuth on Expo/mobile [workaround](https://github.com/better-auth/better-auth/issues/3711). 4. Double-check your Google OAuth redirect URI: it must be a public HTTPS URL (not a custom scheme), registered in both Google Cloud Console and your Better Auth config [redirect URI docs](https://github.com/better-auth/better-auth/issues/4070). 5. Make sure your Expo app’s scheme (in `app.json`) matches what’s in your Better Auth server’s `trustedOrigins`. The backend must append the session cookie to the deep link for the Expo client to pick it up [deep link/cookie propagation](https://github.com/better-auth/better-auth/issues/3711). 6. On Android, if the browser closes during 2FA, try passing `{ showInRecents: true }` to `WebBrowser.openAuthSessionAsync` or prefer Chrome as the browser. This keeps the browser open during 2FA and helps the callback fire [2FA workaround](https://github.com/better-auth/better-auth/issues/1447). 7. Add logging to check if the deep link contains the `cookie` parameter and if SecureStore is saving it after OAuth callback. If missing, it’s likely a trustedOrigins or backend config issue. If these steps don’t resolve it, share your Better Auth config, Expo scheme, and a log of the deep link/callback URL after sign-in for more targeted help. <!-- 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/6b088863-6d96-4184-862d-8dd221f895b1?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/6b088863-6d96-4184-862d-8dd221f895b1?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/6b088863-6d96-4184-862d-8dd221f895b1?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/6b088863-6d96-4184-862d-8dd221f895b1?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6b088863-6d96-4184-862d-8dd221f895b1?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/6b088863-6d96-4184-862d-8dd221f895b1?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6b088863-6d96-4184-862d-8dd221f895b1?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%20with%20Better%20Auth%20v1.4.5%20and%20Expo%2C%20especially%20after%20Google%202FA%20or%20when%20there%E2%80%99s%20no%20active%20browser%20session.%20The%20main%20causes%20are%3A%20%281%29%20a%20bug%20where%20the%20OAuth%20state%20cookie%20uses%20%60SameSite%3DLax%60%2C%20which%20breaks%20state%20validation%20after%20POST%20redirects%20%28fixed%20in%20newer%20versions%29%2C%20and%20%282%29%20Expo/Android%20browser%20quirks%20where%20the%20login%20browser%20closes%20during%202FA%2C%20so%20the%20deep%20link%20callback%20never%20fires%20and%20the%20session%20isn%E2%80%99t%20created%C2%A0%5Bdetails%5D%28https%3A//github.com/better-auth/better-auth/issues/6483%29%C2%A0%5Bexpo/2FA%20browser%20issue%5D%28https%3A//github.com/better-auth/better-auth/issues/1447%29.%0A%0AHere%E2%80%99s%20what%20you%20can%20do%3A%0A%0A1.%20%2A%2AUpgrade%2A%2A%20to%20the%20latest%20%60better-auth%60%20and%20%60%40better-auth/expo%60%20if%20possible.%20This%20resolves%20the%20cookie/state%20bug%20and%20improves%20Expo%20compatibility%C2%A0%5Bupgrade%20advice%5D%28https%3A//github.com/better-auth/better-auth/issues/5034%29.%0A2.%20If%20you%20must%20stay%20on%20v1.4.5%2C%20set%20the%20state%20cookie%20to%20%60SameSite%3DNone%60%20and%20%60Secure%3Dtrue%60%20in%20your%20Better%20Auth%20config%3A%0A%20%20%20%60%60%60ts%0A%20%20%20advanced%3A%20%7B%0A%20%20%20%20%20cookies%3A%20%7B%0A%20%20%20%20%20%20%20state%3A%20%7B%0A%20%20%20%20%20%20%20%20%20attributes%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20sameSite%3A%20%22none%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20secure%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%7D%0A%20%20%20%7D%0A%20%20%20%60%60%60%0A3.%20%2A%2AAfter%2A%2A%20%60await%20authClient.signIn.social%28...%29%60%2C%20immediately%20call%20%60await%20authClient.getSession%28%29%60%20to%20force%20a%20session%20refresh.%20This%20is%20a%20reliable%20workaround%20for%20session%20not%20being%20available%20after%20OAuth%20on%20Expo/mobile%C2%A0%5Bworkaround%5D%28https%3A//github.com/better-auth/better-auth/issues/3711%29.%0A4.%20Double-check%20your%20Google%20OAuth%20redirect%20URI%3A%20it%20must%20be%20a%20public%20HTTPS%20URL%20%28not%20a%20custom%20scheme%29%2C%20registered%20in%20both%20Google%20Cloud%20Console%20and%20your%20Better%20Auth%20config%C2%A0%5Bredirect%20URI%20docs%5D%28https%3A//github.com/better-auth/better-auth/issues/4070%29.%0A5.%20Make%20sure%20your%20Expo%20app%E2%80%99s%20scheme%20%28in%20%60app.json%60%29%20matches%20what%E2%80%99s%20in%20your%20Better%20Auth%20server%E2%80%99s%20%60trustedOrigins%60.%20The%20backend%20must%20append%20the%20session%20cookie%20to%20the%20deep%20link%20for%20the%20Expo%20client%20to%20pick%20it%20up%C2%A0%5Bdeep%20link/cookie%20propagation%5D%28https%3A//github.com/better-auth/better-auth/issues/3711%29.%0A6.%20On%20Android%2C%20if%20the%20browser%20closes%20during%202FA%2C%20try%20passing%20%60%7B%20showInRecents%3A%20true%20%7D%60%20to%20%60WebBrowser.openAuthSessionAsync%60%20or%20prefer%20Chrome%20as%20the%20browser.%20This%20keeps%20the%20browser%20open%20during%202FA%20and%20helps%20the%20callback%20fire%C2%A0%5B2FA%20workaround%5D%28https%3A//github.com/better-auth/better-auth/issues/1447%29.%0A7.%20Add%20logging%20to%20check%20if%20the%20deep%20link%20contains%20the%20%60cookie%60%20parameter%20and%20if%20SecureStore%20is%20saving%20it%20after%20OAuth%20callback.%20If%20missing%2C%20it%E2%80%99s%20likely%20a%20trustedOrigins%20or%20backend%20config%20issue.%0A%0AIf%20these%20steps%20don%E2%80%99t%20resolve%20it%2C%20share%20your%20Better%20Auth%20config%2C%20Expo%20scheme%2C%20and%20a%20log%20of%20the%20deep%20link/callback%20URL%20after%20sign-in%20for%20more%20targeted%20help.)&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/6582)
Author
Owner

@Paola3stefania commented on GitHub (Jan 9, 2026):

hi @ilaloov its your issue still there after updating to the last version of better auth?

<!-- gh-comment-id:3730625659 --> @Paola3stefania commented on GitHub (Jan 9, 2026): hi @ilaloov its your issue still there after updating to the last version of better auth?
Author
Owner

@mehdyouras commented on GitHub (Feb 2, 2026):

It still occurs on 1.4.18

<!-- gh-comment-id:3835106678 --> @mehdyouras commented on GitHub (Feb 2, 2026): It still occurs on 1.4.18
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27883