Integrating Google+ Sign-in android

Updated 22 December 2016

Save

In this blog,
We are going to show you how to integrate the google sign-in in your android application.

Google+ sign-in allow users to sign-in by your Android app with their existing Google account and get their profile information like name, email, profile pic and other details.

 

The main advantage of integrating G+ login is, you can encourage more users to your app by providing fast & easiest way of a registration process.

 

What are the Prerequisites

There are some requirements which is necessary while integrating g+

 

How to implement

Step 1: Enable google+ API and Get configuration file

go to this link

Click on Get A Configuration file button

Screenshot_3

After clicking this button you have to Enable google service for your app with the application name and package name.

 

Screenshot_4

 

After fulfilling the above requirements click to Continue blue button.

 

You have to select the service that which service you want to add in your app.

Before Creating the configuration file We can Enable the Google Sign-In API,

Screenshot_2

 

And for enabling google sign-in api you have to provide the SHA-1 of your signing certificate:

For Windows:

For Mac/Linux:

The keytool utility prompts you to enter a password for the keystore. The default password for the debug keystore is android.

Example:

After Generating the SHA- 1

You can enable the Google Sign-in API

For more information: Signing your App

Then generate the google-services.json file. And download it.

 

Step 2: Add this configuration file to your project.

Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project.

 

Step 3: Add permission to your manifest.xml

 

Step 4: Add a plugin to your project in your top-level build.gradle and your app-level build.gradle files as follows:

 

What to do and How to do

Configure Google Sign-In and the GoogleApiClient object

1- In your sign-in activity’s onCreate method, configure Google Sign-In to request the user data required by your app

Configure sign-in to request the user’s ID, email address, and basic profile. ID and basic profile are included in DEFAULT_SIGN_IN.

2- Build a GoogleApiClient with access to the Google Sign-In API and the options specified by gso.

 

1- Add the SignInButton in your application’s layout:

2-  If you want to customize the button’s size and color scheme. Then google gives the methods to customize:

3- In the Android activity (for example, in the onCreate method), register your button’s OnClickListener to sign in the user when clicked:

 

How to get the sign-in details

1- Simply call the function after clicking the sign-in button

 

2- In the activity’s onActivityResult method, retrieve the sign-in result with getSignInResultFromIntent.

3- After you get the sign-in result,

You can get the profile information.

 

 

 

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home