Saturday, September 10, 2016

Android Firebase - Google Sign in Authentication

Steps to Add Google SignIn to Firebase Android Project

1. Add project Dependencies in the Project Gradle file for Firebase Authentication and Google Play Services.

2. Add Google Services plugin dependency at bottom  of the Module App Gradle.

3. Generate GoogleServices file(google-services.json) from Firebase Console ( for the app.

You will need to provide package name and sha1 key

generate SHA1 key using following on mac

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v -storepass android

4. Copy the file google-services.json under apps directory in android project.

5. Enable Google SignIn method from Firebase Console Project setting.

6. Add SignIn button in layout.xml

7. Modify Activity signature to implement OnClickListener and OnConnectFailedListener interface

8. Instantiate GoogleSignInOption object to request appropriate scope and instantiate GoogleAPIClient

9. Add OnClickListener on the sign in button and call Google SignIn intent

12. Process Google Intent SignIn activity result.

13. Handle result on success and failure.