Google Sign In Setup Guide for Mobile App
This guide will help you set up Google Sign In in your MartFury mobile app.
Prerequisites
- A Google Cloud Platform Account
- A Firebase project (recommended) or standalone Google Cloud project
- Basic knowledge of mobile app development
Step 1: Configure Google Cloud Platform
Option A: Using Firebase (Recommended)
- Go to Firebase Console
- Create a new project or select an existing one
- Add your Android and iOS apps to the project
- Download configuration files:
- Android:
google-services.json→ place inandroid/app/ - iOS:
GoogleService-Info.plist→ place inios/Runner/
- Android:
Option B: Using Google Cloud Console
- Go to Google Cloud Console
- Create a new project or select an existing one
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
Step 2: Create OAuth 2.0 Client IDs
You need to create multiple OAuth client IDs:
Web Client ID (Required)
- In Google Cloud Console → Credentials → Create OAuth client ID
- Application type: Web application
- Name:
MartFury Web Client - Click Create
- Copy the Client ID - this is your
GOOGLE_CLIENT_ID
iOS Client ID (Required for iOS)
- Create OAuth client ID → Application type: iOS
- Bundle ID: Your app's bundle identifier (e.g.,
com.yourcompany.martfury) - Click Create
- Copy the iOS URL scheme (format:
com.googleusercontent.apps.XXXX)
Android Client ID (Required for Android)
- Create OAuth client ID → Application type: Android
- Package name: Your app's package name (e.g.,
com.yourcompany.martfury) - SHA-1 certificate fingerprint:bash
# For debug keystore keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android # For release keystore keytool -list -v -keystore your-release-key.keystore -alias your-alias - Click Create
SHA-1 Fingerprint
You need separate Android OAuth clients for debug and release builds, each with their respective SHA-1 fingerprints.
Step 3: Configure Your Mobile App
Environment Variables
Create or update your .env file:
# Google Sign-In credentials
# Use the Web Client ID (not iOS or Android client IDs)
GOOGLE_CLIENT_ID=your-web-client-id.apps.googleusercontent.com
GOOGLE_SERVER_CLIENT_ID=your-web-client-id.apps.googleusercontent.com
# Enable Google Sign-In
ENABLE_GOOGLE_SIGN_IN=true| Variable | Description |
|---|---|
GOOGLE_CLIENT_ID | Web application OAuth client ID |
GOOGLE_SERVER_CLIENT_ID | Same as above (used for backend verification) |
iOS Configuration
Update your ios/Runner/Info.plist to include the reversed client ID as a URL scheme:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- Add your reversed iOS client ID here -->
<string>com.googleusercontent.apps.YOUR_IOS_CLIENT_ID</string>
</array>
</dict>
</array>Finding Your Reversed Client ID
The reversed client ID is provided in Google Cloud Console when you create the iOS OAuth client. It looks like: com.googleusercontent.apps.123456789-abcdefg
Android Configuration
The google_sign_in Flutter package handles Android configuration automatically. Ensure you have:
google-services.jsoninandroid/app/(if using Firebase)- SHA-1 fingerprint registered in Google Cloud Console
No manual AndroidManifest.xml changes are required.
Step 4: Configure OAuth Consent Screen
- Go to Google Cloud Console → APIs & Services → OAuth consent screen
- Choose External user type (or Internal for organization apps)
- Fill in required fields:
- App name
- User support email
- Developer contact email
- Add scopes:
email,profile,openid - Add test users if app is in testing mode
- Submit for verification (for production)
Step 5: Testing the Integration
- Run your app
- Go to the login screen
- Tap the Google Sign In button
- Select a Google account
- Verify that you're redirected back to your app
Troubleshooting
Common Issues
1. Google Sign In button not showing
- Verify
ENABLE_GOOGLE_SIGN_IN=truein your.envfile - Ensure both
GOOGLE_CLIENT_IDandGOOGLE_SERVER_CLIENT_IDare set - Restart the app completely (hot reload doesn't apply
.envchanges)
2. "Sign In failed" or "ApiException: 10"
This usually means configuration mismatch:
- iOS: Verify the reversed client ID is in Info.plist URL schemes
- Android: Verify SHA-1 fingerprint matches your keystore
- Check that package name/bundle ID matches OAuth client configuration
3. "DEVELOPER_ERROR" on Android
- SHA-1 fingerprint mismatch - regenerate and update in Google Cloud Console
- Package name mismatch between app and OAuth client
- Missing
google-services.jsonfile
4. Sign In works but backend rejects token
- Ensure
GOOGLE_SERVER_CLIENT_IDmatches the Web client ID - Backend must be configured to verify tokens with the same client ID
5. "User cancelled sign-in"
- User tapped outside the account picker or pressed back
- This is expected behavior, not an error
Getting Help
If you encounter any issues:
- Check the Google Sign-In Documentation
- Review the google_sign_in package documentation
- Check your app's logs for detailed error messages
Security Considerations
- Never commit your Google Client IDs to version control
- Always use environment variables for sensitive data
- Implement proper error handling and user feedback
- Verify tokens on your backend before trusting them
