How "Sign in with Google" works with Better-Auth. Four steps, three lines of code.
signIn.social({ provider: "google" })/api/auth/callback/google. Better-Auth verifies the token with Google, gets the user's name + email.user + account (provider: google) + session. Sets the session cookie./. Header shows their Google name. No password needed.user + account (google) + session// Add to betterAuth({ ... }): socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, }, },
// The Google button calls: authClient.signIn.social({ provider: "google", callbackURL: "/", })
Client ID + Client Secret.http://localhost:3001/api/auth/callback/google (dev)https://sitzio.de/api/auth/callback/google (prod)socialProviders.google with the client ID and secret. Set them as env vars, not hardcoded.signIn.social({ provider: "google" })