This guide helps you set up the starter app project with Supabase authentication (Google & Facebook) from scratch.
-
Clone the repository:
git clone https://github.com/your-username/flutter-clean-supabase-starter.git cd flutter-clean-supabase-starter
-
Install dependencies:
flutter pub get
-
Create a project on Supabase.
-
Go to your project's settings > API and copy:
SUPABASE_URL
SUPABASE_ANON_KEY
-
Enable Auth Providers:
- Go to
Authentication > Providers
. - Enable Google and Facebook, and provide their respective credentials.
- Go to
Create a .env
file at the root of your project:
SUPABASE_URL=your-supabase-url
SUPABASE_ANON_KEY=your-anon-key
GOOGLE_WEB_CLIENT_ID=your-google-web-client-id
GOOGLE_IOS_CLIENT_ID=your-google-ios-client-id
Edit your android/app/src/main/AndroidManifest.xml
and add this inside <activity>
:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="com.presyowise"
android:host="auth-callback" />
</intent-filter>
-
Go to Google Cloud Console.
-
Create a project or use an existing one.
-
Go to APIs & Services > Credentials.
-
Click Create Credentials > OAuth Client ID:
- Create each Application Type: Android, Web, IOS
- Provide your SHA-1 certificate fingerprint (use
./gradlew signingReport
in Android Studio). - Add your Android package name (e.g.,
com.example.app
).
-
Folow this step Sign in with Google.
-
Add Authorized redirect URI in Supabase:
<package-name>://auth-callback
-
Go to Facebook for Developers.
-
Follow the Supabase Login with Facebook.
In your auth_datasource.dart
, ensure you handle social sign-in:
Future<AuthResponse> signInWithGoogle() async {
final googleSignIn = GoogleSignIn(
clientId: _iosClientId,
serverClientId: _webClientId,
);
final googleUser = await googleSignIn.signIn();
if (googleUser == null) throw Exception("User cancelled sign in");
final googleAuth = await googleUser.authentication;
if (googleAuth.accessToken == null || googleAuth.idToken == null) {
throw Exception("Missing Google Auth Tokens");
}
return _supabase.auth.signInWithIdToken(
provider: OAuthProvider.google,
idToken: googleAuth.idToken!,
accessToken: googleAuth.accessToken!,
);
}
For Facebook:
Future<bool> signInWithFacebook() async {
return await _supabase.auth.signInWithOAuth(
OAuthProvider.facebook,
redirectTo: kIsWeb
? 'https://<project-ref>.supabase.co/auth/v1/callback'
: '<package-name>://auth-callback',
authScreenLaunchMode: kIsWeb
? LaunchMode.platformDefault
: LaunchMode.externalApplication,
);
}
flutter pub get
flutter run
- Make sure your Supabase project has social login providers enabled.
- Ensure all redirect URLs are added in both Supabase and the third-party providers.
- Confirm that your SHA-1 key and Android package name are correct in Google Console.
- If
flutter pub get
fails, try runningflutter clean
then retry.
- Flutter
- Supabase (Auth, DB)
- Google & Facebook OAuth2
- dotenv for config management