OAuth (Google)
Let users sign in with their Google account. On first sign-in, a Koolbase user account is automatically created.
How it works
Koolbase handles the OAuth flow server-side. Your app opens a browser to the Google auth URL, the user authorises, and Google redirects back to your app with an auth code. Koolbase exchanges the code for a session token and returns it to your app.
Your app calls getGoogleAuthUrl() to get the OAuth redirect URL
Open the URL in a browser or WebView — user signs in with Google
Google redirects back to your app deep link with a code parameter
Your app calls signInWithGoogle(code) — Koolbase exchanges the code and returns a session
If no account exists for this Google email, one is created automatically
Setup
Before using Google OAuth, configure your Google Client ID in the Koolbase dashboard under Project → Settings → OAuth Providers.
Google Cloud Console
https://api.koolbase.com/v1/sdk/auth/oauth/callbackSign in with Google
import 'package:url_launcher/url_launcher.dart';
// Step 1: Get the Google auth URL
final authUrl = await Koolbase.auth.getGoogleAuthUrl();
// Step 2: Open in browser
await launchUrl(Uri.parse(authUrl), mode: LaunchMode.externalApplication);
// Step 3: In your deep link handler, extract the code
// e.g. myapp://auth/callback?code=4/0AX4...
final code = Uri.parse(incomingLink).queryParameters['code'];
// Step 4: Exchange the code for a Koolbase session
final session = await Koolbase.auth.signInWithGoogle(code: code!);
print(session.user.email); // user@gmail.com
print(session.user.verified); // true — Google emails are pre-verifiedAccount linking
If a user with the same email already exists (registered with email/password), signing in with Google will link the OAuth account to the existing user. The user can then sign in with either method.
Email matching
user@gmail.com via email/password, signing in with Google using the same Gmail address will link to that account — not create a duplicate.