1
votes

I am developing an app where users can log in with Google+. I added the Google+ sign in button and the user can log in without any issues.

Where I am having trouble is in retrieving the friends/ people in circles. This feature is not in the Android API, so I am trying to achieve this with an HTTP request (as documented here)

I set up my application in the developer console with a Public API access Android Key.

When I use an HttpGet with this URL:

https://www.googleapis.com/plus/v1/people/{the user's g+ id}/people/visible?key={my API key from the console}

I get a "keyInvalid" error with a "Bad Request" message.

If I try it without "?key={my key}" I get a "dailyLimitExceedingUnreg" error with message "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."

Do you know why my reqest isn't working? What can I do to get it to work?

3

3 Answers

1
votes

Okay, it turns out I didn't need to use HTTP get. Thanks for your responses.

This code did the trick:

Plus.PeopleApi.loadVisible(mGoogleApiClient,null).setResultCallback(new ResultCallback<People.LoadPeopleResult>() {
        @Override
        public void onResult(People.LoadPeopleResult loadPeopleResult) {
            if (loadPeopleResult.getStatus().getStatusCode() == CommonStatusCodes.SUCCESS) {
                PersonBuffer personBuffer = loadPeopleResult.getPersonBuffer();
                try {
                    int count = personBuffer.getCount();
                    for (int i = 0; i < count; i++) {
                        Log.d(TAG, "Person " + i + " name: " + personBuffer.get(i).getDisplayName()+ " - id: " + personBuffer.get(i).getId());
                    }
                } finally {
                    personBuffer.close();
                }


            } else {
                Log.e(TAG, "Error");
            }
        }
    });
0
votes

You need to log in to http://console.developers.google.com and get an API key, the instead of ?key= you should put ?key=RANDOMCHARACTERS replacing RANDOMCHARACTERS for the key you got from Google.

If you haven't created a project, first you'll need to create one in that website, after that you should see the list of available API, search for the Google+ API and enable it to get the corresponding key.

0
votes

People.list is an API method that requires user authentication not application authentication. Basically the only way you can make the request is like this:

GET https://www.googleapis.com/plus/v1/people/me/people/visible?access_token={user access_token}