An Android application demonstrating Google Sign-In authentication using Supabase Auth with Kotlin.
This project uses:
- Supabase Auth
- Google Identity Services (Credential Manager)
- Material Components
- Kotlin Coroutines
- Google Sign-In using Supabase
- Secure ID Token authentication
- Session persistence
- Auto-login on app restart
- Logout functionality
- Display logged-in user name
- Material Design UI
- Kotlin
- Android SDK
- Supabase Kotlin SDK
- Google Identity Services
- Material Components
- User selects Google account.
- App retrieves Google ID Token.
- ID Token is sent to Supabase.
- Supabase verifies token and creates session.
- Session is persisted locally.
- User is automatically logged in on next launch.
git clone https://github.com/TutorialsAndroid/SupaBaseGoogleSignIn.git- Go to https://supabase.com
- Create a new project
- Enable Google provider in:
Authentication → Providers → Google
- Add your Google Web Client ID & Secret
You must create:
Used inside the app for setServerClientId.
Required for SHA-1 verification.
Steps:
-
Go to Google Cloud Console
-
APIs & Services → Credentials
-
Create OAuth Client ID
-
Add:
- Package name
- SHA-1 (from
signingReport)
Enable:
- Google Identity Services API
Add this to local.properties:
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_anon_public_key
GOOGLE_WEB_CLIENT_ID=your_web_client_idKeys are loaded into BuildConfig via Gradle.
Make sure your build.gradle includes:
buildConfigField("String", "SUPABASE_URL", "\"${localProperties["SUPABASE_URL"]}\"")
buildConfigField("String", "SUPABASE_ANON_KEY", "\"${localProperties["SUPABASE_ANON_KEY"]}\"")
buildConfigField("String", "GOOGLE_WEB_CLIENT_ID", "\"${localProperties["GOOGLE_WEB_CLIENT_ID"]}\"")Supabase restores session asynchronously.
To prevent race conditions, a short coroutine delay is used before checking:
delay(200)
if (supabase.auth.currentSessionOrNull() != null) {
navigateToHome()
}lifecycleScope.launch {
supabase.auth.signOut()
}App.kt → Supabase initialization
SignInActivity.kt → Google login
HomeActivity.kt → Display user info + logout
- Uses Supabase
anonpublic key (safe for client apps) - Never expose
service_rolekey - Enable Row Level Security (RLS) in Supabase
- Google SHA-1 verification required
- Emulator must have Google Play image
- A Google account must be added on device
- SHA-1 must match Android OAuth client
- Splash screen auth state observer
- MVVM architecture
- Profile editing
- Upload avatar
- Store additional user data in database