[GH-ISSUE #193] redirectURI does not seem to be working in google social provider #16798

Closed
opened 2026-04-15 14:47:19 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @benquan on GitHub (Oct 16, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/193

Describe the bug
redirectURI does not seem to be working in google social provider (keeps sending the default path)
I have set google to respond to: 'http://localhost:5173/auth/callback/google' but better-auth sends the default: http://localhost:5173/api/auth/callback/google

To Reproduce
Set a social provider in auth.ts definition:

export const auth = betterAuth({
	database: drizzleAdapter(db, {
		provider: 'sqlite' // or "mysql", "sqlite"
	}),
	emailAndPassword: {
		enabled: true
	},
	socialProviders: {
		google: {
			redirectURI: 'http://localhost:5173/auth/callback/google',
			clientId: process.env.GOOGLE_ID as string,
			clientSecret: process.env.GOOGLE_SECRET as string
		}
	}
});

Then sign in to google:

<button
	on:click={async () => {
		await authClient.signIn.social({
			provider: 'google',
		});
	}}
>
	Continue with Google
</button>

Expected behavior
This should run you through the google oauth screens, but I get this error:

Screenshots
Screenshot 2024-10-16 at 8 58 01 AM

Screenshot 2024-10-16 at 8 58 22 AM

Better-auth is ignoring redirectURI and is passing the default: redirect_uri=http://localhost:5173/api/auth/callback/google

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Chrome
  • Version: 129
Originally created by @benquan on GitHub (Oct 16, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/193 **Describe the bug** redirectURI does not seem to be working in google social provider (keeps sending the default path) I have set google to respond to: 'http://localhost:5173/auth/callback/google' but better-auth sends the default: http://localhost:5173/api/auth/callback/google **To Reproduce** Set a social provider in auth.ts definition: ``` export const auth = betterAuth({ database: drizzleAdapter(db, { provider: 'sqlite' // or "mysql", "sqlite" }), emailAndPassword: { enabled: true }, socialProviders: { google: { redirectURI: 'http://localhost:5173/auth/callback/google', clientId: process.env.GOOGLE_ID as string, clientSecret: process.env.GOOGLE_SECRET as string } } }); ``` Then sign in to google: ``` <button on:click={async () => { await authClient.signIn.social({ provider: 'google', }); }} > Continue with Google </button> ``` **Expected behavior** This should run you through the google oauth screens, but I get this error: **Screenshots** <img width="1056" alt="Screenshot 2024-10-16 at 8 58 01 AM" src="https://github.com/user-attachments/assets/fbad766e-3a8b-4c6e-b7ae-d8e6c818cb9f"> <img width="569" alt="Screenshot 2024-10-16 at 8 58 22 AM" src="https://github.com/user-attachments/assets/9324fdcc-e6ad-4294-a105-94a245e6d4c6"> Better-auth is ignoring redirectURI and is passing the default: redirect_uri=http://localhost:5173/api/auth/callback/google **Desktop (please complete the following information):** - OS: OSX - Browser: Chrome - Version: 129
GiteaMirror added the locked label 2026-04-15 14:47:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16798