Step 1: Google Cloud Console Setup
Go to Google Cloud Console.
Create a project if you don’t already have one.
In the search bar (top center), type “Credentials” and select Credentials under “Products & Pages”.
Click the Create Credentials button.
Select OAuth Client ID from the pop-up window.
Choose the appropriate Application Type (iOS, Web, or Android).
We will now proceed with platform-specific setup instructions.
Step 2: iOS Setup
Select iOS under the Application Type dropdown.
Enter a name (e.g., “iOS OAuth”) and your app’s Bundle ID (found in
ios/Runner/Info.plist
under theCFBundleIdentifier
tag).Click the Create button.
Add to Info.plist:
<array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>com.googleusercontent.apps.***YOUR_CLIENT_ID***</string> </array> </dict> </array>
Replace
YOUR_CLIENT_ID
with the generated Client ID.
Step 3: Web Setup
Select Web application under the Application Type dropdown.
Enter a name (e.g., “Web OAuth”).
Add Authorized JavaScript origins and Authorized redirect URIs:
Use
http://localhost
for local debugging.Use
https://yourdomain.com
for production.
Click Create to generate your Client ID.
Step 4: Android Setup
Select Android under the Application Type dropdown.
Enter a name (e.g., “Android OAuth Debug” for debugging and “Android OAuth Release” for production).
Obtain SHA-1 Keys:
Navigate to the
android
folder in your project:cd android
Run the following command to generate SHA-1 keys:
./gradlew signInReport
Use the appropriate SHA-1 key for both debug and release configurations.
Update build.gradle:
In
android/build.gradle
, add:classpath 'com.google.gms:google-services:4.3.15'
In
android/app/build.gradle
, add:implementation 'com.google.android.gms:play-services-auth:20.4.1'
Configure Signing Configurations:
Save the
key.jks
file inside theandroid/app/
directory of your Flutter project.Update
android/app/build.gradle
to include signing configurations:
android { signingConfigs { debug { storeFile file('key.jks') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } release { storeFile file('key.jks') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig = signingConfigs.debug } release { signingConfig = signingConfigs.release } } }