Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Google+ unable to get auth code
    text
    copied!<p>I'm trying to get a Google+ auth code based on this article: <a href="https://developers.google.com/+/mobile/android/sign-in#server-side_access_for_your_app" rel="noreferrer">Server-side access for your app</a>. However, whenever I run my app and try to get the code I get the following in LogCat:</p> <pre><code>07-23 23:42:31.760: E/getAccessToken()(11114): [ERROR] GoogleAuthException: com.google.android.gms.auth.GoogleAuthException: Unknown </code></pre> <p>I browsed a lot of stuff and from what I can tell I have everything setup correctly in the code below. Any ideas why it's not getting an auth token?</p> <p>FYI, I have one project setup in the API console that has both the app and web applications configured for oauth and I'm using the server (not the app) ID for the scopes string. I've also followed the example(s) from the above link and the app works fine and allows you to sign-in/out, but I just can't get the auth code.</p> <pre><code>private String getAccessToken() { String scopesString = Scopes.PLUS_LOGIN + " " + Scopes.PLUS_PROFILE; String scope = "oauth2:server:client_id:" + SERVER_CLIENT_ID + ":api_scope:" + scopesString; Bundle appActivities = new Bundle(); appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "http://schemas.google.com/AddActivity"); String code = null; try { code = GoogleAuthUtil.getToken( this, // Context context mPlusClient.getAccountName(), // String accountName scopes, // String scope appActivities // Bundle bundle ); } catch (IOException transientEx) { // network or server error, the call is expected to succeed if you try again later. // Don't attempt to call again immediately - the request is likely to // fail, you'll hit quotas or back-off. Log.e("getAccessToken()", "[ERROR] IOException: " + transientEx); return null; } catch (UserRecoverableAuthException e) { // Recover Log.e("getAccessToken()", "[ERROR] UserRecoverableAuthException: " + e); code = null; } catch (GoogleAuthException authEx) { // Failure. The call is not expected to ever succeed so it should not be // retried. Log.e("getAccessToken()", "[ERROR] GoogleAuthException: " + authEx); return null; } catch (Exception e) { Log.e("getAccessToken()", "[ERROR] Exception: " + e); throw new RuntimeException(e); } return code; } </code></pre>
 

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