Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call https://www.googleapis.com/plus/v1/people/me at google
    primarykey
    data
    text
    <p>I am developing an Android application and need to get the "me" info from google but I always ends up in either response code 401 or 403. What am I doing wrong? Here is my code:</p> <pre><code>private static final String GOOGLE_AUTH_TOKEN_TYPE = "oauth2:https://www.googleapis.com/auth/plus.me"; </code></pre> <p>I get the oauth token by (note...code below is shortened):</p> <pre><code>Account googleAccount = (AccountManager) getSystemService(ACCOUNT_SERVICE).getAccountsByType("com.google")[0]; final Bundle bundle = manager.getAuthToken(googleAccount, GOOGLE_AUTH_TOKEN_TYPE, true, null, null).getResult(); String authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); </code></pre> <p>So far so good... I now have a token so everything looks good here.</p> <p>Now get the me info:</p> <pre><code>String GOOGLE_ME_URL = "https://www.googleapis.com/plus/v1/people/me"; final DefaultHttpClient client = new DefaultHttpClient(); final HttpGet request = new HttpGet(GOOGLE_ME_URL); request.addHeader("Authorization", "OAuth=" + authToken); final HttpResponse response = client.execute(request); </code></pre> <p>This gives response code 401.</p> <p>I have also tried:</p> <pre><code>final DefaultHttpClient client = new DefaultHttpClient(); final HttpGet request = new HttpGet(GOOGLE_ME_URL + "?access_token=" + authToken); final HttpResponse response = client.execute(request); </code></pre> <p>This gives response code 403 - Something like "Daily limit exceeded. Please sign up".</p> <p>What am I doing wrong? what have I missed? How should this be done?</p> <p>Thanks</p> <p>// Edits below Some more investigation: I added a project into code.google.com/apis/console and took the key generated from there and put into the url, like: <a href="https://www.googleapis.com/plus/v1/people/me?key=my_generated_key&amp;access_token=" rel="noreferrer">https://www.googleapis.com/plus/v1/people/me?key=my_generated_key&amp;access_token=</a>" + authToken. Now the call works fine and I get a 200 response with the correct info. But I really don´t want to use this method if I don´t have to and according to google I should not need to "•If the request requires authorization (such as a request for an individual's private data), then it must include an OAuth 2.0 token. It may also include the API key, but it doesn't have to." - from developers.google.com/+/api/oauth.</p> <p>Another thing: If I try another url like "<a href="https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=" rel="noreferrer">https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=</a>" + authToken it works fine.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload