Constant constants for email using GoogleApiClient.Builder

A list of Google+ authorization areas is here: https://developers.google.com/+/api/oauth . Fine ...

In the QuickStart example for the Android client, the code to get the GoogleApiClient instance looks like the one below, but with the "Plus.SCOPE_PLUS_LOGIN" area. But I want to have an "email" area. I can not find the constant for the "email" area.

  private GoogleApiClient buildGoogleApiClient() {
// When we build the GoogleApiClient we specify where connected and
// connection failed callbacks should be returned, which Google APIs our
// app uses and which OAuth 2.0 scopes our app requests.
return new GoogleApiClient.Builder(this)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .addApi(Plus.API, Plus.PlusOptions.builder().build())
    .addScope(Plus.SCOPE_PLUS_LOGIN) // I WANT AN email SCOPE!!!
    .build();

}

Do I need to create an instance of Scope? For instance:

Scope emailScope = new Scope("email"); // like this?????
+4
source share
2 answers

Plus.AccountApi.getAccountName() :

// Note mGoogleApiClient must be connected for this to work
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);

:

, Google Play. AndroidManifest.xml <uses-permission android:name="android.permission.GET_ACCOUNTS" />.

+4

. :

     Builder builder = new GoogleApiClient.Builder(this)
    .addApi(Plus.API)
    .addScope(Plus.SCOPE_PLUS_PROFILE)
    .addScope(new Scope("https://www.googleapis.com/auth/userinfo.email"))
0

All Articles