Why does the PlusClient.loadPeople function fail with an HTTP 403 error?

I have an old Google Plus API (aka Google Play Service) built into my application, and now I'm trying to update everything to use the V2 API, which includes, among other things, accessing a list of people in a person’s circle.

Allegedly, the only changes I had to make was to update the OAuth profile that I use for authentication:

_plusClient = new PlusClient.Builder(_activity, this, this). setScopes(Scopes.PLUS_LOGIN).build(); 

and then (after making the necessary hoop to make sure everything is connected), making a request for the user's friends:

  _plusClient.loadPeople(new PlusClient.OnPeopleLoadedListener() { public void onPeopleLoaded (ConnectionResult status, PersonBuffer people, String nextPageToken) { // ... } }, com.google.android.gms.plus.model.people.Person.Collection.VISIBLE); 

However, this results in a ConnectionResult.NETWORK_ERROR message. In Android logs, I see the following:

  E/Volley (13590): [4053] BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/plus/v1/people/me/people/visible?maxResults=100&orderBy=alphabetical 

My old code made REST requests manually after using PlusClient to get an automatic OAuth token (via GoogleAuthUtil.getToken ). Therefore, in order to get information about the basic user profile, I finished issuing the HTTP request as follows:

 https://www.googleapis.com/oauth2/v1/userinfo?auth_token=XXX 

This worked hard for userinfo and continues to work for userinfo with V2 code. However, if I try to manually display the users visible using the REST API with the request, as shown below:

 https://www.googleapis.com/plus/v1/people/me/people/visible?auth_token=XXX 

I get a 403 response with the following JSON block:

  { "error": { "errors": [ { "domain": "usageLimits", "reason": "accessNotConfigured", "message": "Access Not Configured" } ], "code": 403, "message": "Access Not Configured" } } 

From what I can learn from the documentation, there is no need to get and configure the Google API key for integrating Google Plus into the Android application through the Google Play Services code. Indeed, in the API there is no such key that confirms this suspicion.

I have a Google API key connected to my Android app for GCM. In order to avoid this API key getting mixed up in all of this somehow, I ensured that Google+ is enabled for this API key, but this did not cause the 403 answer to magically disappear.

I tested the https://www.googleapis.com/plus/v1/people/me/people/visible request through the API built into the REST API docs for Google+ and it works there. I see people from my circles in JSON results.

I noticed that these requests have an API key superimposed on the URL:

 https://www.googleapis.com/plus/v1/people/me/people/visible?key=AIzaSyCFj15TpkchL4OUhLD1Q2zgxQnMb7v3XaM 

So I tried to create an API key for my Android application (using the same Google API project that I use for GCM), and applied it to the URL in the code that manually tries to download the friends list. This request fails with error 401 saying that the authorization information is bad. I assume that the authentication token that I get from the Google Plus SDK code is somehow obtained through another “API project” (for example, the one used by the Google Plus Android application), and when I transfer my own key, everything becomes everything is good.

I still have not tried to eliminate all use of the Google Play Services Google+ SDK and just get the OAuth access token. I rather hoped that this would work, and I would not have to spend so much time investigating this. Therefore, perhaps someone from the Universe either got a job on Google+, or can point me in a useful direction.

+4
source share
2 answers

Have you registered an open public certificate in .apk format in the Google API console? If not, you can find instructions on how to do this here .

+8
source

make sure you add google + api access. and the client key created using SHA1 and the full package of projects in the android manifest file

0
source

All Articles