I tried to follow tutorial: https://developers.google.com/android/guides/http-auth.
Code:
token = GoogleAuthUtil.getToken(getApplicationContext(),
On this docs page https://developers.google.com/+/mobile/android/sign-in the example has a good explanation for this exception.
In particular, it looks like this line should be noted:
Requesting an authorization code will always throw UserRecoverableAuthException on the first call to GoogleAuthUtil.getToken
catch (UserRecoverableAuthException e) {
// Requesting an authorization code will always throw
// UserRecoverableAuthException on the first call to GoogleAuthUtil.getToken
// because the user must consent to offline access to their data. After
// consent is granted control is returned to your activity in onActivityResult
// and the second call to GoogleAuthUtil.getToken will succeed.
startActivityForResult(e.getIntent(), AUTH_CODE_REQUEST_CODE);
return;
}