Invalid Callback URL on expo IOS when doing Google oauth

Hello everyone, I’m trying out Better Auth and I’m running into an issue with my google oauth. Error:
2025-04-12T14:00:21.709Z ERROR [Better Auth]: Invalid callbackURL: business-copilot:///
2025-04-12T14:00:22.223Z INFO [Better Auth]: If it's a valid URL, please add business-copilot:/// to trustedOrigins in your auth config
Current list of trustedOrigins: exp://,http://localhost:8081
ERROR {"code": "INVALID_CALLBACKURL", "message": "Invalid callbackURL", "status": 403, "statusText": ""}
2025-04-12T14:00:21.709Z ERROR [Better Auth]: Invalid callbackURL: business-copilot:///
2025-04-12T14:00:22.223Z INFO [Better Auth]: If it's a valid URL, please add business-copilot:/// to trustedOrigins in your auth config
Current list of trustedOrigins: exp://,http://localhost:8081
ERROR {"code": "INVALID_CALLBACKURL", "message": "Invalid callbackURL", "status": 403, "statusText": ""}
package version:
"@better-auth/expo": "^1.2.6-beta.8",
"better-auth": "1.2.6-beta.6",
"@better-auth/expo": "^1.2.6-beta.8",
"better-auth": "1.2.6-beta.6",
Relevant code: app.json
"scheme": "business-copilot",
"scheme": "business-copilot",
auth.ts
trustedOrigins: ['exp://'],
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
trustedOrigins: ['exp://'],
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
authClient.ts
export const authClient = createAuthClient({
baseURL:
process.env.BETTER_AUTH_URL /* base url of your Better Auth backend. */,
disableDefaultFetchPlugins: true,
plugins: [
expoClient({
scheme: 'business-copilot',
storage: SecureStore,
}),
organizationClient(),
anonymousClient(),
phoneNumberClient(),
],
});
export const authClient = createAuthClient({
baseURL:
process.env.BETTER_AUTH_URL /* base url of your Better Auth backend. */,
disableDefaultFetchPlugins: true,
plugins: [
expoClient({
scheme: 'business-copilot',
storage: SecureStore,
}),
organizationClient(),
anonymousClient(),
phoneNumberClient(),
],
});
Sign-in.tsx
const onGoogleButtonPress = useCallback(async () => {
const { error, data } = await authClient.signIn.social({
provider: 'google',
callbackURL: '/recent-businesses',
});
if (error) {
console.error(error);
}
}, []);
const onGoogleButtonPress = useCallback(async () => {
const { error, data } = await authClient.signIn.social({
provider: 'google',
callbackURL: '/recent-businesses',
});
if (error) {
console.error(error);
}
}, []);
Behaviour: Web: works as expected On iOS (and android I guess): throws error relating to the scheme Please can someone help me out. I would very much appreciate
Solution:
add business-copilot:/// as a trusted origin in your auth config
Jump to solution
4 Replies
Solution
bekacru
bekacru2w ago
add business-copilot:/// as a trusted origin in your auth config
ak11
ak11OP2w ago
hmmm. ok i’ll try that but i felt /// was a bug or something cause i was using the expo example huge thanks for the quick reply Hey @bekacru , i've done that but now another issue after the google sign in, the webview cloes and takes me back to my app but it doesn't carry me to the callbackURL stated. instead it remains on the signin page. i would have to restart the app before it takes me in. should i manually call "router.replace" after google sigin in ? or should betterAuth take care of that? cause on the expo example i see this
useEffect(() => {
if (isAuthenticated) {
if (navContainerRef.isReady()) {
router.push("/dashboard");
}
}
}, [isAuthenticated, navContainerRef.isReady()]);
useEffect(() => {
if (isAuthenticated) {
if (navContainerRef.isReady()) {
router.push("/dashboard");
}
}
}, [isAuthenticated, navContainerRef.isReady()]);
`
bekacru
bekacru2w ago
there is an issue with expo deep linking specially on expo go. Either do development build or use some kind effect like the expo example to navigate based on session
ak11
ak11OP2w ago
i'm on dev client but i'll try that useEffect thanks for your help really

Did you find this page helpful?