Hello, I need the user to use his google play account on the first login to the application and I can receive at least his email. Is it possible, if so then point to the idea or tell me an example of implementation.

1 answer 1

Configure login options:

// Configure sign-in to request the user's ID, email address, and basic // profile. ID and basic profile are included in DEFAULT_SIGN_IN. GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); 

Then do a GoogleApiClient

 // Build a GoogleApiClient with access to the Google Sign-In API and the // options specified by gso. mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); 

And then we actually call authorization activity.

 private void signIn() { Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); } 

https://developers.google.com/identity/sign-in/android/start off. the documentation is worth starting with.