SSO Plugin does not work with Expo Client #2071

Closed
opened 2026-03-13 09:24:52 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @mprync on GitHub (Oct 3, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Setup an expo app with better-auth
Install the SSO plugin
Try to login using SSO

Current vs. Expected behavior

It does not allow you to finish the flow, it will just 404 because SSO plugin may not work with Expo Client

What version of Better Auth are you using?

1.3.25

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:54 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T6041",
    "release": "25.0.0",
    "cpuCount": 16,
    "cpuModel": "Apple M4 Max",
    "totalMemory": "48.00 GB",
    "freeMemory": "0.38 GB"
  },
  "node": {
    "version": "v24.5.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.5.1"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "Unknown",
    "config": null
  }
}

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

Client

Auth config (if applicable)


Additional context

No response

Originally created by @mprync on GitHub (Oct 3, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Setup an expo app with better-auth Install the SSO plugin Try to login using SSO ### Current vs. Expected behavior It does not allow you to finish the flow, it will just 404 because SSO plugin may not work with Expo Client ### What version of Better Auth are you using? 1.3.25 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:54 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T6041", "release": "25.0.0", "cpuCount": 16, "cpuModel": "Apple M4 Max", "totalMemory": "48.00 GB", "freeMemory": "0.38 GB" }, "node": { "version": "v24.5.0", "env": "development" }, "packageManager": { "name": "npm", "version": "11.5.1" }, "frameworks": null, "databases": null, "betterAuth": { "version": "Unknown", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the expo label 2026-03-13 09:24:52 -05:00
Author
Owner

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

The SSO plugin in Better Auth relies on web-based redirect flows and expects the client to handle redirects and maintain state between the authorization request and callback. Expo Client has limitations with deep linking and redirect URI handling, which often leads to 404 errors or state mismatches in SSO/OAuth flows. There is no platform-specific workaround for Expo in the SSO plugin code, so these issues are expected when using Expo Client for SSO flows. Workarounds that help with other plugins (like polyfilling crypto) do not address the redirect/state handling required for SSO. For OAuth-based SSO in Expo, you need to ensure your redirect URIs use a public domain (not localhost), configure your app's scheme and trusted origins, and handle deep links using expo-linking, but even then, Expo Client's limitations may prevent a seamless SSO experience citation citation citation citation.

If you need SSO/OAuth to work reliably, consider building your app as a standalone Expo app (not running in Expo Go), where you can register custom schemes and handle redirects more robustly. Magic link and non-OAuth methods are not affected by these issues.

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 3, 2025): <!-- Answer --> The SSO plugin in Better Auth relies on web-based redirect flows and expects the client to handle redirects and maintain state between the authorization request and callback. Expo Client has limitations with deep linking and redirect URI handling, which often leads to 404 errors or state mismatches in SSO/OAuth flows. There is no platform-specific workaround for Expo in the SSO plugin code, so these issues are expected when using Expo Client for SSO flows. Workarounds that help with other plugins (like polyfilling crypto) do not address the redirect/state handling required for SSO. For OAuth-based SSO in Expo, you need to ensure your redirect URIs use a public domain (not localhost), configure your app's scheme and trusted origins, and handle deep links using expo-linking, but even then, Expo Client's limitations may prevent a seamless SSO experience [citation](https://github.com/better-auth/better-auth/issues/5055) [citation](https://github.com/better-auth/better-auth/issues/4070) [citation](https://github.com/better-auth/better-auth/issues/3711) [citation](https://github.com/better-auth/better-auth/discussions/3982). If you need SSO/OAuth to work reliably, consider building your app as a standalone Expo app (not running in Expo Go), where you can register custom schemes and handle redirects more robustly. Magic link and non-OAuth methods are not affected by these issues. <!-- 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/13238eb9-9bed-4ed4-a06a-68bc747681d7?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/13238eb9-9bed-4ed4-a06a-68bc747681d7?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/13238eb9-9bed-4ed4-a06a-68bc747681d7?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/13238eb9-9bed-4ed4-a06a-68bc747681d7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/13238eb9-9bed-4ed4-a06a-68bc747681d7?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/13238eb9-9bed-4ed4-a06a-68bc747681d7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/13238eb9-9bed-4ed4-a06a-68bc747681d7?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/5072)
Author
Owner

@mprync commented on GitHub (Oct 4, 2025):

@dosu I am not using Expo Go, the schema and deep link works just fine but the expo client is always showing this error once I click the account to login

https://***.ngrok-free.app/api/auth/error/error?error=invalid_provider&error_description=missing_user_info#

This works just fine on web though. This doesn't look like it's a redirect issue.

@mprync commented on GitHub (Oct 4, 2025): @dosu I am not using Expo Go, the schema and deep link works just fine but the expo client is always showing this error once I click the account to login `https://***.ngrok-free.app/api/auth/error/error?error=invalid_provider&error_description=missing_user_info# ` This works just fine on web though. This doesn't look like it's a redirect issue.
Author
Owner

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

The error means Better Auth couldn't find the required user info (usually email or id) from your SSO provider during the callback. This isn't platform-specific—it's triggered if the provider's response is missing those fields, which can happen if the provider returns different claims or scopes depending on the client type or environment (web vs. Expo) citation.

Here’s what to check:

  • Make sure the scopes and claims requested in Expo match what you use on web (especially openid, email, profilecitation.
  • Log the provider’s response (ID token and userInfo endpoint) in Expo and compare it to web—see if email and id are present.
  • Double-check your provider config and mapping in Better Auth to ensure it matches the fields actually returned by your provider in Expo.
  • If you’re using a custom scheme or deep link, confirm your app’s scheme is set in app.json and included in trustedOrigins on the server citation.
  • After sign-in, call await authClient.getSession() to force a session refresh in Expo.

If you share your provider config and a log of the provider’s response from Expo, I can help pinpoint what’s missing.

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 4, 2025): <!-- Answer --> The error means Better Auth couldn't find the required user info (usually `email` or `id`) from your SSO provider during the callback. This isn't platform-specific—it's triggered if the provider's response is missing those fields, which can happen if the provider returns different claims or scopes depending on the client type or environment (web vs. Expo) [citation](https://github.com/better-auth/better-auth/blob/6e5ecd69a0b2505e51011e54bba527191556ad30/packages/better-auth/src/plugins/sso/index.ts). Here’s what to check: - Make sure the scopes and claims requested in Expo match what you use on web (especially `openid`, `email`, `profile`) [citation](https://github.com/better-auth/better-auth/discussions/4473). - Log the provider’s response (ID token and userInfo endpoint) in Expo and compare it to web—see if `email` and `id` are present. - Double-check your provider config and mapping in Better Auth to ensure it matches the fields actually returned by your provider in Expo. - If you’re using a custom scheme or deep link, confirm your app’s scheme is set in `app.json` and included in `trustedOrigins` on the server [citation](https://github.com/better-auth/better-auth/issues/3711). - After sign-in, call `await authClient.getSession()` to force a session refresh in Expo. If you share your provider config and a log of the provider’s response from Expo, I can help pinpoint what’s missing. <!-- 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/ee7bea05-06e5-4e9b-8e59-411cac20a1e2?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/ee7bea05-06e5-4e9b-8e59-411cac20a1e2?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/ee7bea05-06e5-4e9b-8e59-411cac20a1e2?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/ee7bea05-06e5-4e9b-8e59-411cac20a1e2?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ee7bea05-06e5-4e9b-8e59-411cac20a1e2?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/ee7bea05-06e5-4e9b-8e59-411cac20a1e2?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ee7bea05-06e5-4e9b-8e59-411cac20a1e2?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/5072)
Author
Owner

@mprync commented on GitHub (Oct 4, 2025):

For anyone interested, the SSO plugin does not work with Expo client and the callback url never returns with the session, better off going a full custom implementation to handle SSO.

@mprync commented on GitHub (Oct 4, 2025): For anyone interested, the SSO plugin does not work with Expo client and the callback url never returns with the session, better off going a full custom implementation to handle SSO.
Author
Owner

@Bekacru commented on GitHub (Oct 6, 2025):

https://***.ngrok-free.app/api/auth/error/error?error=invalid_provider&error_description=missing_user_info#

This seems like the sso plugin wasn't able to get the user info as expected. Does this provider works with a web client?

@Bekacru commented on GitHub (Oct 6, 2025): `https://***.ngrok-free.app/api/auth/error/error?error=invalid_provider&error_description=missing_user_info# ` This seems like the sso plugin wasn't able to get the user info as expected. Does this provider works with a web client?
Author
Owner

@Akashamba commented on GitHub (Oct 7, 2025):

i too had some issues with expo and better-auth with google sso. for now i just did await authClient.signIn.social({ provider: "google", callbackURL: "/", }); and redirect with a useEffect when the session changes. this works for now, but would love to hear if this is the best or even a good solution.

@Akashamba commented on GitHub (Oct 7, 2025): i too had some issues with expo and better-auth with google sso. for now i just did ```await authClient.signIn.social({ provider: "google", callbackURL: "/", });``` and redirect with a useEffect when the session changes. this works for now, but would love to hear if this is the best or even a good solution.
Author
Owner

@dosubot[bot] commented on GitHub (Jan 6, 2026):

Hi, @mprync. I'm Dosu (https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that Better Auth SSO plugin (v1.3.25) does not work properly with the Expo Client, causing a 404 error and missing user info during login.
  • The issue is linked to Expo Client's inherent limitations with redirect URI handling and deep linking.
  • Using a standalone Expo app instead of the Expo Client is the recommended workaround.
  • Other users have confirmed similar problems and shared partial workarounds, but no fully reliable solution exists for Expo Client.
  • The issue is considered resolved with the recommendation to avoid Expo Client for SSO.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of better-auth or if you need further assistance.
  • If no response is received, I will automatically close this issue in 7 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Jan 6, 2026): Hi, @mprync. I'm Dosu (https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that Better Auth SSO plugin (v1.3.25) does not work properly with the Expo Client, causing a 404 error and missing user info during login. - The issue is linked to Expo Client's inherent limitations with redirect URI handling and deep linking. - Using a standalone Expo app instead of the Expo Client is the recommended workaround. - Other users have confirmed similar problems and shared partial workarounds, but no fully reliable solution exists for Expo Client. - The issue is considered resolved with the recommendation to avoid Expo Client for SSO. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of better-auth or if you need further assistance. - If no response is received, I will automatically close this issue in 7 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2071