I have android, google authorization issue (similar to .GoogleAuthException: Unknown while doing Google SSO. - no answers):
09-29 00:04:38.328: W/System.err(15623): com.google.android.gms.auth.GoogleAuthException: Unknown
09-29 00:04:38.328: W/System.err(15623): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
It is reproducable when i execute the following code:
String scopesString = Scopes.PLUS_LOGIN + " " + Scopes.PLUS_PROFILE;
String scopes = "oauth2:server:client_id:" + Consts.GOOGLE_PLUS_SERVER_CLIENT_ID + ":api_scope:" + scopesString;
OR
String scopes = "audience:server:client_id:" + Consts.GOOGLE_PLUS_SERVER_CLIENT_ID;
Bundle appActivities = new Bundle();
appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "http://schemas.google.com/AddActivity http://schemas.google.com/BuyActivity");
GoogleAuthUtil.getToken(activity, accountName, scopes, appActivities);
Here are some notes:
- I can get access token with GoogleAuthUtil.getToken(activity, accountName, "oauth2:" + scopesString)
- activity != null, client_id = 123456789.apps.googleusercontent.com, accountName is valid email (selected with account picker)
- accountName in http://plus.google.com/u/0/apps has a record about my project: <Project Name> ------- app and purchase activity--------Your circles
- I have
android.permission.GET_ACCOUNTS
- The same exception with appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "")
- The same exception with GoogleAuthUtil.getToken(activity, accountName, scopes)
SOLVED
- You should have 2 Client Ids: Installed App (Android) and Service one. You should use Service one here.
- Then you will get UserRecoverableAuthException: NeedPermission. You should handle exception
i.e. like this:
} catch (UserRecoverableAuthException e) {
activity.startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
}