2

I'm developing an Android application and I need to retrieve user profile picture. I already use OAuth to get the token as described here: http://android-developers.blogspot.it/2013/01/verifying-back-end-calls-from-android.html

Any,I'm not able to correctly retrieve user's info. I've tried with this:

https://www.googleapis.com/plus/v1/people/me?key={YOUR_API_KEY}

But I'm not able to understand what's the KEY: On my google console I have:

  • Client ID for web application
  • Client ID for Android application
  • Key for server applications
  • Key for Android applications

Which of them is the correct key? I'm a bit confused. I use the Client ID for web when retrieving the token and to verify it on the backend. I use the Client ID for Android to check on backend side that the issuer is between Authorized Parties. Anyway, when I make a request to:

https://www.googleapis.com/plus/v1/people/me?key={YOUR_API_KEY}

I always get a 401,400,or 403 saying:

  • "Access Not Configured. Please use Google Developers Console to activate the API for your project."
  • Bad Requeset
  • "Invalid Credentials"

and so on.

I've also tried to look at this question with no luck: How to call https://www.googleapis.com/plus/v1/people/me at google

But if I try to query the Google+ API from the Google Cloud Console I successfully get all the info.

What am I doing wrong?

Community
  • 1
  • 1
edoardotognoni
  • 2,752
  • 3
  • 22
  • 31
  • Hey @edoardotognoni, I've submitted a bug report on this because neither the Android or iOS Key created in the credentials area, actually work for API calls. If possible, could you star it there so that it might get the proper attention and maybe fixed? URL: https://code.google.com/p/google-plus-platform/issues/detail?id=1206&sort=-id&colspec=ID%20Type%20Status%20Component%20Owner%20Summary%20Stars – seaders Aug 29 '15 at 21:25

1 Answers1

3

Preparation

The Getting Started with G+ page explains how you get the Key.

Follow the "Step 1: Enable the Google+ API" and you'll sort it out.

Here's the Google Developers Console snippet: enter image description here

Of course, you have to enable the Google+ API in the console: enter image description here

This is an example "page" inquiry:

https://www.googleapis.com/plus/v1/people/115657794332822874007?key=my_key 

And the result:

{
 "kind": "plus#person",
 "etag": "\"7zDxHg5s5mqDKJRPJZIoOsdfecE/hQCtSSux92KyaIK9CGzq7XZppYY\"",
 "urls": [
  {
   "value": "http://www.osijek360.com",
   "type": "website",
   "label": "www.osijek360.com"
  },
  {
   "value": "https://plus.google.com/+Osijek360/about",
   "type": "other",
   "label": "OSIJEK360 (page)"
  },
  {
   "value": "https://www.facebook.com/OSIJEK360",
   "type": "other",
   "label": "OSIJEK360 (fan page)"
  },
  {
   "value": "http://www.webonjee.com",
   "type": "other",
   "label": "------------------------------------\u003e www.webonjee.com"
  },
  {
   "value": "https://www.facebook.com/webonjee.osijek",
   "type": "other",
   "label": "Webonjee Osijek (profile)"
  },
  {
   "value": "https://www.facebook.com/WEBONJEE",
   "type": "other",
   "label": "WEBONJEE™ (page)"
  },
  {
   "value": "https://www.twitter.com/WEBONJEE",
   "type": "other",
   "label": "WEBONJEE™ (profile)"
  },
  {
   "value": "http://www.linkedin.com/in/webonjee",
   "type": "other",
   "label": "WEBONJEE™ (profile)"
  }
 ],
 "objectType": "page",
 "id": "115657794332822874007",
 "displayName": "OSIJEK360",
 "tagline": "Osječki web portal sa 3D – 360º virtualnim šetnjama i panoramama",
 ...
}

/me request

Once configured correctly, you also need to provide an access_token to be able to use /me request, as explained in the API documentation:

If using the userId value "me", this method requires authentication using a token that has been granted the OAuth scope https://www.googleapis.com/auth/plus.login or https://www.googleapis.com/auth/plus.me. Read more about OAuth.

Saran
  • 3,845
  • 3
  • 37
  • 59
  • Yes but in this case I'm using GoogleApis, it is not possible to get the info through HttpGet? – edoardotognoni Mar 19 '14 at 14:30
  • 1
    You need an API key for the service to allow returning the data to you. This is how Google controls who gets access to particular data. – Booger Mar 19 '14 at 14:32
  • Ok thank you, now it's clear. Anyway, I've tried to use the Google+ API in Android in addition with GoogleAuthUtil to get the token and it is working. Anyway, if I pase the link on the browser (https://www.googleapis.com/plus/v1/people/me?key=xxxxxxxxxxxx) the result is still 401 invalid credentials. Maybe it is not possible to get it through a Web Browser? – edoardotognoni Mar 20 '14 at 08:36
  • I've added further details. TL;DR: you need to provide an `access_token`. – Saran Mar 20 '14 at 14:20
  • @edoardotognoni did you try the request with the `access_token`? – Saran Mar 21 '14 at 09:41
  • Yes I've tried but with no result. Anyway I solved it using Google Apis for Android – edoardotognoni Mar 21 '14 at 09:48
  • It's not working because I think I'm retrieving the token without using che right scope. For now I'm using: "audience:server:client_id:" + WEB_APP_CLIENT_ID – edoardotognoni Mar 21 '14 at 09:52
  • @Saran Since the design for console is changes is it possible to update screen shots, ( I can not find my api_key too) – Reza Jun 25 '16 at 21:16