Сейчас я добавляю логин Google в свое приложение. но я получил токен, который пришел из этой области scope = "oauth2:" + Scopes.PLUS_LOGIN
, но сервер не может получить электронную почту пользователя по этому токену. поэтому я добавил свою область "https://www.googleapis.com/auth/userinfo.email" с одним пробелом. но я получаю только системную ошибку. как это
06-19 15:26:33.444 25229-25460/ W/System.err﹕ com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission 06-19 15:26:33.445 25229-25460/ W/System.err﹕ в com.google.android.gms.auth.GoogleAuthUtil.getToken(неизвестный источник) 06-19 15:26:33.447 25229-25460/ W/System.err﹕ на com.google.android.gms.auth.GoogleAuthUtil.getToken( Неизвестный источник)
Я совершенно не понимаю, какое разрешение мне нужно. и это тоже мой код.
AsyncTask task = new AsyncTask() {
@Override
protected Object doInBackground(Object... params) {
final String CLIENT_ID = "abc123.apps.googleusercontent.com";
final List<String> SCOPES = Arrays.asList(new String[]{
"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/userinfo.email"
});
try {
String scopes = String.format("oauth2:server:client_id:%s:api_scope:%s", CLIENT_ID , TextUtils.join(" ", SCOPES));
String token = GoogleAuthUtil.getToken(context, Plus.AccountApi.getAccountName(mGoogleApiClient), scopes);
userInfo = new GoogleUserInfo(email, finalPersonPhotoUrl, currentPerson.getId(), token, currentPerson.getDisplayName());`enter code here`
}
catch (UserRecoverableAuthException e) {
// This error is recoverable, so we could fix this
// by displaying the intent to the user.
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
catch (GoogleAuthException e) {
e.printStackTrace();
}
return null;
}
};
task.execute((Void) null);
Как я могу получить токен, который может получать информацию о пользователе по электронной почте? ? ?