0

The documentation here says the following

Warning: The Google+ Sign-In button and the plus.login scope used by Google+ Sign-In, are not currently supported for use with the Google+ Domains API. Requests that are made to the Google+ Domains API using an authentication token granted for the https://www.googleapis.com/auth/plus.login scope, or generated by the Google+ Sign-In button, will fail.

So if we need to access Google Plus Domains API how do we do it using GoogleApiClient object in android? I want a list of a user's circles for which I need to use the Domains API.

akshay1188
  • 1,647
  • 2
  • 17
  • 35

1 Answers1

0

Consider using GoogleAuthUtil for Google Plus Domain authentication.

And most importantly: "Domain API will work only with domain email id" (which is not the gmail id).

String scopes = "oauth2:" + "https://www.googleapis.com/auth/plus.me " +
            "https://www.googleapis.com/auth/plus.circles.read";  
String accountName = "domain_email_id_used_for_login";//fetch from AccountManager or ask the user to enter
String token = "";
try {
        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this);
        token = sharedPref.getString("token", "");
        if (!token.equals("")) {
            GoogleAuthUtil.clearToken(LoginActivity.this, token);
        }
        token = GoogleAuthUtil.getToken(LoginActivity.this,
                        accountName, scopes);
        GoogleCredential googleCredential = new GoogleCredential().setAccessToken(token);
        PlusDomains plusDomains = new PlusDomains.Builder(new NetHttpTransport(), new JacksonFactory(), googleCredential).setApplicationName("GPlusLab").build();
        plusDomains.people().get("me").execute();
                return token;
    } catch (UserRecoverableAuthException e) {
                startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
    } catch (GoogleAuthException e) {
                e.printStackTrace();
    } catch (IOException e) {
                e.printStackTrace();
    }

github link to complete example.

Rohan
  • 86
  • 3
  • Strange, it appears I can use the regular Google+ API authentication to use the Google+ Domains API on Google's API Explorer. So, maybe that would work? – tekNorah Mar 03 '16 at 01:07