๐ Google Authentication
Set up Google Sign-In for your ExpoBase app on both iOS and Android.
Prerequisites
- Google Cloud Console account
- Supabase project configured
Step 1: Create Google Cloud Project
-
Go to Google Cloud Console:
- Visit Google Cloud Console
- Select your project or create a new one
-
Enable Google Sign-In API:
- Go to APIs & Services โ Library
- Search for "Google Sign-In API"
- Click Enable
-
Configure OAuth Consent Screen:
- Go to APIs & Services โ OAuth consent screen
- Select External user type
- Fill in the required fields (App name, User support email, Developer contact)
- Add scopes:
email,profile,openid - Click Save and Continue
Step 2: Create OAuth 2.0 Credentials
You need to create 3 OAuth Client IDs in Google Cloud Console:
2.1 Web Application Client (Required for Supabase + Android)
- Go to APIs & Services โ Credentials
- Click Create Credentials โ OAuth 2.0 Client ID
- Select Web application as application type
- Enter a name (e.g., "ExpoBase Web Client")
- Add Authorized redirect URIs:
(Replace
https://YOUR_PROJECT_REF.supabase.co/auth/v1/callbackYOUR_PROJECT_REFwith your Supabase project reference) - Click Create
- Copy the Client ID and Client Secret
โ ๏ธ Important: The Web Client ID is used by both Supabase and Android. Keep the Client ID and Secret safe!
2.2 iOS Client (Required for iOS)
- Click Create Credentials โ OAuth 2.0 Client ID
- Select iOS as application type
- Enter a name (e.g., "ExpoBase iOS Client")
- Enter your Bundle ID:
com.yourcompany.yourapp - Click Create
- Copy the iOS Client ID
2.3 Android Client (Required for Android)
- Click Create Credentials โ OAuth 2.0 Client ID
- Select Android as application type
- Enter a name (e.g., "ExpoBase Android Client")
- Enter your Package name:
com.yourcompany.yourapp - Add your SHA-1 certificate fingerprint (see below)
- Click Create
Getting SHA-1 Fingerprint
For Development (Debug keystore):# macOS/Linux
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
# Windows
keytool -list -v -keystore %USERPROFILE%\.android\debug.keystore -alias androiddebugkey -storepass android -keypass androideas credentials --platform androidSelect your project, then select Keystore โ View credentials. Copy the SHA-1 fingerprint.
โ ๏ธ Important: You need two Android OAuth clients - one for debug SHA-1 (development) and one for production SHA-1 (release builds). Both should use the same package name but different SHA-1 fingerprints.
Step 3: Configure Supabase
-
Go to Supabase Dashboard:
- Visit Supabase Dashboard
- Select your project
-
Enable Google Provider:
- Go to Authentication โ Providers
- Find Google and toggle Enable
- Add your Client ID: Your Web Client ID (from Step 2.1)
- Add your Client Secret: Your Web Client Secret (from Step 2.1)
- Click Save
Step 4: Configure Your App
Update app.json:
{
"expo": {
"plugins": [
[
"@react-native-google-signin/google-signin",
{
"iosUrlScheme": "com.googleusercontent.apps.YOUR_IOS_CLIENT_ID"
}
]
]
}
}Replace YOUR_IOS_CLIENT_ID with the reversed iOS Client ID. For example, if your iOS Client ID is:
123456789-abcdefg.apps.googleusercontent.comThen your iosUrlScheme should be:
com.googleusercontent.apps.123456789-abcdefgUpdate .env.local:
# iOS Client ID (for iOS Sign-In)
EXPO_PUBLIC_GOOGLE_CLIENT_ID=YOUR_IOS_CLIENT_ID.apps.googleusercontent.com
# Web Client ID (for Android Sign-In)
EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID=YOUR_WEB_CLIENT_ID.apps.googleusercontent.com
Update .env.template:
# --- Google ----
# iOS Client ID (from Google Cloud Console - iOS app type)
EXPO_PUBLIC_GOOGLE_CLIENT_ID=
# Web Client ID (from Google Cloud Console - Web application type) - Required for Android
EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID=
Step 5: Rebuild Your App
After adding the Google Sign-In configuration, you must rebuild the native app:
# For development
npx expo prebuild --clean
npx expo run:ios
# or
npx expo run:android
# For EAS Build
eas build --platform ios
eas build --platform androidPlatform-Specific Summary
| Platform | Client ID Used | Configuration |
|---|---|---|
| iOS | iOS Client ID | iosClientId in GoogleSignin.configure() |
| Android | Web Client ID | webClientId in GoogleSignin.configure() |
| Supabase | Web Client ID + Secret | Dashboard โ Authentication โ Providers |
Troubleshooting
Android: DEVELOPER_ERROR
This error means Google can't verify your app. Check:
-
Package name matches in:
- Google Cloud Console (Android OAuth client)
app.jsonโandroid.package
-
SHA-1 fingerprint is correct:
- For dev builds: Use debug keystore SHA-1
- For EAS builds: Use
eas credentialsto get SHA-1
-
Web Client ID is set in
GoogleSignin.configure():GoogleSignin.configure({ webClientId: process.env.EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID, iosClientId: process.env.EXPO_PUBLIC_GOOGLE_CLIENT_ID, });
Android: Invalid API key (Supabase)
This error comes from Supabase, not Google. Check:
-
Supabase Google Provider is configured:
- Dashboard โ Authentication โ Providers โ Google
- Web Client ID and Secret are filled in
-
Supabase URL and Anon Key are correct in
.env.local
iOS: Sign-In button doesn't work
- Verify
iosUrlSchemeinapp.jsonis the reversed iOS Client ID - Rebuild the app after changing
app.json - Check that
EXPO_PUBLIC_GOOGLE_CLIENT_IDis set
"Google hasn't verified this app" warning
This is normal during development. Click Advanced โ Go to [app name] (unsafe) to continue. For production:
- Submit your app for Google OAuth verification
- Go to OAuth consent screen โ Publish app
Ready to Use
Google authentication is already implemented! Users can:
- โ Sign in with Google account on iOS
- โ Sign in with Google account on Android
- โ Auto-create account on first login
- โ Link with existing accounts
Check the implementation in:
context/AuthContext.tsx- Google Sign-In logicapp/(auth)folder - Google login buttons
๐ฏ Next Step
Continue to ๐๏ธ Prepare Build to run the setup script.
Step 10/11 Complete โ
Google authentication configured for iOS & Android!
