【发布时间】:2014-01-31 23:26:41
【问题描述】:
我的目标是在不进行任何服务器端工作的情况下获取用户的基本个人资料信息(名字、姓氏等)。而且我不想在用户界面上使用 Google+ 登录按钮。
我可以毫无问题地收到用户的电子邮件。所以下一步是获取访问令牌来获取配置文件,这是我的代码
String token = null;
try {
token = GoogleAuthUtil.getToken(getApplicationContext(), email, SCOPE);
} catch (final UserRecoverableAuthException e) {
startActivityForResult(e.getIntent(), REQUEST_CODE_AUTH_GOOGLE_ACCOUNT);
} catch (IOException e) {
Log.e(TAG, e.toString());
} catch (GoogleAuthException e) {
Log.e(TAG, e.toString());
}
我已经定义了范围
private static final String SCOPE = "oauth2:https://www.googleapis.com/auth/userinfo.profile";
当我运行我的应用程序时,出现“com.google.android.gms.auth.GoogleAuthException: Unknown”异常。我也尝试过其他范围,例如 Scope.PLUS_LOGIN、Scope.PLUG_PROFILE。但他们都给了我同样的例外。
顺便说一句,在 Google API 控制台中,我已经设置了一个客户端 ID。
我已经坚持了 2 天。任何帮助将非常感激。
【问题讨论】:
标签: android google-authentication