I have the old Google Plus (aka Google Play Service) API integrated into my app, and now I'm trying to update things to use the V2 API which includes, among other things, access to the list of people in a person's circles.
Ostensibly, the only changes I should have had to make are to update the OAuth profile I'm using to authenticate:
_plusClient = new PlusClient.Builder(_activity, this, this).
setScopes(Scopes.PLUS_LOGIN).build();
and then (after doing the necessary hoop jumping to ensure that things are 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 ConnectionResult.NETWORK_ERROR
being reported. I can see in the Android logs 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 the REST requests manually after using the PlusClient to obtain an OAuth auto token (via GoogleAuthUtil.getToken
). So to obtain a user's basic profile info, I ended up issuing an HTTP request like so:
https://www.googleapis.com/oauth2/v1/userinfo?auth_token=XXX
This worked peachily for userinfo
and continues to work for userinfo
with the V2 code. However, if I try to manually fetch a user's visible people via the REST API, with a request like the following:
https://www.googleapis.com/plus/v1/people/me/people/visible?auth_token=XXX
I get a 403 response with the following JSON blob:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
From what I can glean via the documentation, it is not necessary to obtain and configure a Google API key to integrate Google Plus into an Android app via the Google Play Services code. Indeed, there's nowhere in the API to supply such a key, which corroborates this suspicion.
I happen to have a Google API key connected to my Android app for GCM. On the off chance that that API key is somehow being mixed up in all of this, I have ensured that Google+ is enabled for that API key, but that did not make the 403 response magically go away.
I have tested a https://www.googleapis.com/plus/v1/people/me/people/visible
request via the API explorer embedded in the REST API docs for Google+ and it works there. I can see the people in my circles in the JSON results.
I noticed that those requests appear to have an API key slapped onto the URL:
https://www.googleapis.com/plus/v1/people/me/people/visible?key=AIzaSyCFj15TpkchL4OUhLD1Q2zgxQnMb7v3XaM
So I tried creating an API key for my Android app (using the same Google API project that I'm using for GCM), and tacking that onto the URL in the code that manually attempts to load the friends list. This request fails with a 401 error saying that the authorization information is bad. I assume that the auth token I get back from the Google Plus SDK code is somehow obtained through a different "API project" (like maybe the one used by the Android Google Plus app) and when I pass my own key, things get all wonky.
I haven't gone so far a to try to eliminate all use of the Google Play Services Google+ SDK and just obtain an OAuth access token myself. I was rather hoping this would just work and I wouldn't have to waste so much time investigating it. So perhaps someone out in the universe has either gotten this Google+ stuff working or can point me in a useful direction.
Did you register your digitally signed .apk file's public certificate in the Google APIs Console? If not, you can find instructions on how to do it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With