I have a function that attempts to get a token to query the Drive API:
private void getAuthTokenBlocking() {
try {
Account account = AccountManager.get(sActivity).getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE)[0];
sToken = GoogleAuthUtil.getToken(sActivity, account.name, DriveScopes.DRIVE_READONLY);
} catch (GooglePlayServicesAvailabilityException playEx) {
Dialog alert = GooglePlayServicesUtil.getErrorDialog(
playEx.getConnectionStatusCode(),
sActivity,
AUTH_REQUEST_CODE);
alert.show();
} catch (UserRecoverableAuthException userAuthEx) {
userAuthEx.printStackTrace();
} catch (IOException transientEx) {
transientEx.printStackTrace();
} catch (GoogleAuthException authEx) {
authEx.printStackTrace();
}
}
But I always get the following errors:
com.google.android.gms.auth.GoogleAuthException: Unknown
com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
I have tried all the solutions I could see, including prefixing the scope with "oauth2:".