I’m developing an application on Android and I want to allow users to log in with their Google account. How can I achieve this?
Go to the Security section of your Google Account. Under “Third-party apps with account access,” select Manage third-party access. Select the app or service you want to review.
You can use your Google Account to sign in to third-party apps and services. You won't have to remember individual usernames and passwords for each account. Third-party apps and services are created by companies or developers that aren't Google. Go to an app or service you trust.
You might want to authenticate the user using one of the google account already configured in your device like some of the apps do, for that follow the below link -
"Authenticating to OAuth2 Services" - http://developer.android.com/training/id-auth/authenticate.html
Download Sample from Google - Android SDK Manager/Extras/Google Play Services
In simple steps it does
This is another link which is good in explaining the process - http://android-developers.blogspot.in/2013/01/verifying-back-end-calls-from-android.html
you can follow below steps for Login in your app
Below is response format of above "userinfo" call
{ "id": "ID", "name": "NAME", "given_name": "GiVEN NAME", "family_name": "FAMILY_NAME", "link": "https://plus.google.com/ID", "picture": "https://PHOTO.jpg", "gender": "GENDER", "locale": "LOCALE" }
If you want Email id along with that response you have to modify
SCOPE = "oauth2:https://www.googleapis.com/auth/userinfo.profile";
to
SCOPE = "oauth2:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email";
in that sample
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With