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:
Code Block |
---|
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>***IF YOU HAVE FACEBOOK SIGN-IN CLIENT ID, TYPE HERE***</string>
<string>com.googleusercontent.apps.***YOUR_CLIENT_ID***</string>
</array>
</dict>
</array> |
Replace
YOUR_CLIENT_ID
with the generated Client ID.Note: AddingGoogleService-Info.plist
is not required.
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:Code Block cd android
Run the following command to generate SHA-1 keys:
Code Block ./gradlew signInReport
Use the appropriate SHA-1 key for both debug and release configurations.
Update build.gradle:
In
android/build.gradle
, add:Code Block classpath 'com.google.gms:google-services:4.3.15'
In
android/app/build.gradle
, add:Code Block 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:
Code Block |
---|
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 } } } |