Expo with Google doesn't work on iOS or Android #757

Closed
opened 2026-03-13 08:03:06 -05:00 by GiteaMirror · 8 comments
Owner

Originally created by @dj-nuo on GitHub (Mar 1, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Following this guide: https://www.better-auth.com/docs/integrations/expo

Regular emai/password login & sign-up DO WORK.
Google - doesn't.

Can you plz provide the right way to get Goggle's GOOGLE_CLIENT_ID & GOOGLE_CLIENT_SECRET ?
Followed this guide: https://www.better-auth.com/docs/authentication/google
I got it as Web Client (GOOGLE_CLIENT_ID & GOOGLE_CLIENT_SECRET).

What am I missing? Is there somewhere truly ent-to-end guide?

For example, in Google Cloud Console there is an option to create OAuth for iOS and Android (instead of Web), but then where shall the "iOS URL scheme" for example be put?

Here is my client (Expo) using development build:

import { createAuthClient } from 'better-auth/react';
import { expoClient } from '@better-auth/expo/client';
import * as SecureStore from 'expo-secure-store';
import expoAppConfig from '../../app.json';

export const authClient = createAuthClient({
  baseURL: process.env.EXPO_PUBLIC_SERVER_URL /* base url of your Better Auth backend. */,
  plugins: [
    expoClient({
      scheme: 'myapp',
      storagePrefix: 'myapp',
      storage: SecureStore,
    }),
  ],
});


  const handleLogin = async () => {
    await authClient.signIn.social({
      provider: 'google',
      callbackURL: '/dashboard', // this will be converted to a deep link (eg. `myapp://dashboard`) on native
    });
  };

And my server code (ElysiaJS):

import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "../../db";
import {
  account,
  session,
  user,
  verification,
} from "@server/db/schema/auth-schema";
import { expo } from "@better-auth/expo";

export const auth = betterAuth({
  plugins: [expo()],
  trustedOrigins: ["myapp://", "http://localhost:3000"],
  database: drizzleAdapter(db, {
    provider: "pg",
    schema: {
      user,
      session,
      verification,
      account,
    },
  }),
  emailAndPassword: {
    enabled: true, // If you want to use email and password auth
  },
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID! as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET! as string,
    },
  },
});




Current vs. Expected behavior

I tried it using iOS development build in the simulator.

What version of Better Auth are you using?

1.2.0

Provide environment information

- OS: MacOS Sequoia 15.3.1
- NodeJS: v23.8.0
- Bun: 1.2.2
- Expo: expo@52.0.37

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

Client

Auth config (if applicable)


Additional context

No response

Originally created by @dj-nuo on GitHub (Mar 1, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Following this guide: https://www.better-auth.com/docs/integrations/expo **Regular emai/password login & sign-up DO WORK**. **Google - doesn't**. Can you plz provide the right way to get Goggle's GOOGLE_CLIENT_ID & GOOGLE_CLIENT_SECRET ? Followed this guide: https://www.better-auth.com/docs/authentication/google I got it as Web Client (GOOGLE_CLIENT_ID & GOOGLE_CLIENT_SECRET). What am I missing? Is there somewhere truly ent-to-end guide? For example, in Google Cloud Console there is an option to create OAuth for iOS and Android (instead of Web), but then where shall the "iOS URL scheme" for example be put? Here is my client (Expo) using development build: ```javascript import { createAuthClient } from 'better-auth/react'; import { expoClient } from '@better-auth/expo/client'; import * as SecureStore from 'expo-secure-store'; import expoAppConfig from '../../app.json'; export const authClient = createAuthClient({ baseURL: process.env.EXPO_PUBLIC_SERVER_URL /* base url of your Better Auth backend. */, plugins: [ expoClient({ scheme: 'myapp', storagePrefix: 'myapp', storage: SecureStore, }), ], }); const handleLogin = async () => { await authClient.signIn.social({ provider: 'google', callbackURL: '/dashboard', // this will be converted to a deep link (eg. `myapp://dashboard`) on native }); }; ``` And my server code (ElysiaJS): ```javascript import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { db } from "../../db"; import { account, session, user, verification, } from "@server/db/schema/auth-schema"; import { expo } from "@better-auth/expo"; export const auth = betterAuth({ plugins: [expo()], trustedOrigins: ["myapp://", "http://localhost:3000"], database: drizzleAdapter(db, { provider: "pg", schema: { user, session, verification, account, }, }), emailAndPassword: { enabled: true, // If you want to use email and password auth }, socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID! as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET! as string, }, }, }); ``` ### Current vs. Expected behavior I tried it using iOS development build in the simulator. ### What version of Better Auth are you using? 1.2.0 ### Provide environment information ```bash - OS: MacOS Sequoia 15.3.1 - NodeJS: v23.8.0 - Bun: 1.2.2 - Expo: expo@52.0.37 ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:03:06 -05:00
Author
Owner

@ejjsharpe commented on GitHub (Mar 2, 2025):

Hello. I was having this issue too. There is a bug in the expo plugin. I have just put a PR in here

https://github.com/better-auth/better-auth/pull/1634

Also, web client for the google client ID and secret is fine 👍 . You have done everything right here. Make sure to keep the callback URL as this is a required field (this is not mentioned in docs).

I will probably put a PR into the docs too as I agree its unclear and there are a couple of key bits of info missing. I'm just struggling to actually install the dependencies and get the project running. For now you should be able to just patch this as its only a one letter change 👍

@ejjsharpe commented on GitHub (Mar 2, 2025): Hello. I was having this issue too. There is a bug in the expo plugin. I have just put a PR in here https://github.com/better-auth/better-auth/pull/1634 Also, web client for the google client ID and secret is fine 👍 . You have done everything right here. Make sure to keep the callback URL as this is a required field (this is not mentioned in docs). I will probably put a PR into the docs too as I agree its unclear and there are a couple of key bits of info missing. I'm just struggling to actually install the dependencies and get the project running. For now you should be able to just patch this as its only a one letter change 👍
Author
Owner

@so-uvik commented on GitHub (Apr 21, 2025):

Hello, did any of you accomplish google sign in/out using better-auth? I still can't get it to work. If yes, it would be helpful if you provide a repo link that has google auth setup done and working.
Thank you.

@so-uvik commented on GitHub (Apr 21, 2025): Hello, did any of you accomplish google sign in/out using better-auth? I still can't get it to work. If yes, it would be helpful if you provide a repo link that has google auth setup done and working. Thank you.
Author
Owner

@KevinMartinezC commented on GitHub (Apr 25, 2025):

having same issue it works for IOS but it does not for android

@KevinMartinezC commented on GitHub (Apr 25, 2025): having same issue it works for IOS but it does not for android
Author
Owner

@martin-prochazka commented on GitHub (May 30, 2025):

Hi, I am having issue with both Google and Discord. iOS works, Android not. I am using development builds.

On Android after signing up on providers page, it redirects to localhost address which says "This site can't be reached". On iOS it redirects correctly to index route (callbackURL: "/").

@martin-prochazka commented on GitHub (May 30, 2025): Hi, I am having issue with both Google and Discord. iOS works, Android not. I am using development builds. On Android after signing up on providers page, it redirects to localhost address which says "This site can't be reached". On iOS it redirects correctly to index route (callbackURL: "/").
Author
Owner

@A-MacAulay commented on GitHub (Jun 27, 2025):

Is there currently a workaround or fix for this issue?

@A-MacAulay commented on GitHub (Jun 27, 2025): Is there currently a workaround or fix for this issue?
Author
Owner

@karolopolko commented on GitHub (Jun 29, 2025):

Is there currently a workaround or fix for this issue?

@A-MacAulay I had this issue yesterday and spent 1–2 hours fixing it. I ended up having to manually delete every installed app from the Android device—probably because of leftover app schemes? Anyway, it worked

@karolopolko commented on GitHub (Jun 29, 2025): > Is there currently a workaround or fix for this issue? @A-MacAulay I had this issue yesterday and spent 1–2 hours fixing it. I ended up having to manually delete every installed app from the Android device—probably because of leftover app schemes? Anyway, it worked
Author
Owner

@himself65 commented on GitHub (Sep 12, 2025):

Any updates? can someone confirm that if latest version is okay? Or I will close this in next week

@himself65 commented on GitHub (Sep 12, 2025): Any updates? can someone confirm that if latest version is okay? Or I will close this in next week
Author
Owner

@ping-maxwell commented on GitHub (Sep 30, 2025):

If anyone is running into issues please open a new issue with detailed information.

@ping-maxwell commented on GitHub (Sep 30, 2025): If anyone is running into issues please open a new issue with detailed information.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#757