I'm building an app which needs to retrieve personal informations (specifically, complete name, profile picture and cover picture) from the logged google account and I'm trying to do this without implementing the Google+ Sign In, which I think is an overkill in my specific case.
This is the GoogleAccountCredential object I'm using to authenticate
credential = GoogleAccountCredential.usingOAuth2(
getApplicationContext(), Arrays.asList(SCOPES))
.setBackOff(new ExponentialBackOff())
.setSelectedAccountName(settings.getString(PREF_ACCOUNT_NAME, null));
whereas SCOPES is
private static final String[] SCOPES = {CalendarScopes.CALENDAR_READONLY, CalendarScopes.CALENDAR, "profile", "email", "https://www.googleapis.com/auth/plus.login" };
now, when I launch the application I get correctly asked permissions to use the requested informations:
https://www.dropbox.com/s/e11y0gnnemfgu02/Screenshot_2015-08-11-19-41-08~01.png?dl=0
When I want to retrieve the required data, I execute an AsyncTask where I make the following GET request
CloseableHttpResponse response = httpClient.execute(new HttpGetHC4("https://www.googleapis.com/plus/v1/people/me"));
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
Log.d("ProfileTask", result.toString() );
and I get as a response this
{ "error":
{ "errors":
[ { "domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console" } ],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." }}
Now:
- I have enabled in my Google Developer Console the Google+ API (I actually tried enabling it and disabling it to see if it makes any difference: it doesn't) with an OAuth credential tied to the SHA1 fingerprint of the application
- I have also enabled the Calendar API and I don't get any error from its requests
I also tried making GET requests using a Public API key created, such as
GET https://www.googleapis.com/plus/v1/people/me?key={MY_API_KEY}
just to have the same result or even getting an error where it said "ipRefererBlocked There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
What am I doing wrong? Have I misunderstood the functioning of these APIs? How else can I retrieve these data without signing with Google+?
Thanks a lot for your help.
EDIT: I tried accessing also using the accessToken got from credentials.getToken() in http request:
GET https://www.googleapis.com/plus/v1/people/me?accesstoken={ACCESS_TOKEN}
to no avail, same error as before.