0

I try to make a Google-Login on my app!

And it works, perfectly.

But i would like to get a String or Number that is unique for User and App. So that i can Authorize it on my own Server...

My actually way is:

  • Andorid connect to Google
  • Google send login facts to android
  • Android send login state to my server

But for the last step i ned to get an unique value like a number or String.

Thank you for your idee's

Flo
  • 1,179
  • 3
  • 15
  • 43

2 Answers2

0

Google+ profiles have one unique value with a key of id. This value is specific to the Google account and will never change. If you authenticate the user with the email scope, the profile will also contain the users email address with type of account. This can be useful to associate Google+ profiles with existing authentication systems or databases.

To get this info you would have to make a request to people.get with a userId of me and authenticated as the current user

abraham
  • 46,583
  • 10
  • 100
  • 152
0

You can also try for current Logged In Person like:

Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);

System.out.println("ID:\t" + currentPerson.getId());
System.out.println("Display Name:\t" + currentPerson.getDisplayName());
System.out.println("Image URL:\t" + currentPerson.getImage().getUrl());
System.out.println("Profile URL:\t" + currentPerson.getUrl());

before that you must have to initialized mGoogleApiClient:

// [START create_google_api_client]
// Build GoogleApiClient with access to basic profile
mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Plus.API)
        .addScope(new Scope(Scopes.PROFILE))
        .addScope(new Scope(Scopes.EMAIL))
        .build();
// [END create_google_api_client]

Reference Link you can Visit Here.

Thank you.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437