【发布时间】:2014-09-27 16:41:59
【问题描述】:
我正在尝试使用 Oauth2 对登录我设备的 google 用户进行身份验证。我已创建客户端 ID,但无法获得预期结果。
代码是:
String mScope="oauth2:server:client_id:NNNNNNNNNNN.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/plus.login";
protected Void doInBackground(String... accountName) {
Log.i("Inside on AsynTask:","I am here");
String accName=accountName[0];
try {
token1 = GoogleAuthUtil.getToken(Web_view_demo.this,
accName,
mScope);
Log.i("Inside on AsynTask:","I am here");
} catch (IOException transientEx) {
// Network or server error, try later
Log.e("IO", transientEx.toString());
} catch (UserRecoverableAuthException e) {
// Recover (with e.getIntent())
Log.e("UserRecover", e.toString());
//Intent recover = e.getIntent();
//startActivityForResult(recover, 1);
} catch (GoogleAuthException authEx) {
// The call is not ever expected to succeed
// assuming you have already verified that
// Google Play services is installed.
Log.e("GoogleAuth", authEx.toString());
}
Log.i("Token:",token1);
return null;
}
错误是:
com.google.android.gms.auth.GoogleAuthException: Unknown
非常感谢您的帮助。
谢谢。
【问题讨论】:
-
我面临同样的问题。我再次检查调试和发布密钥库 SHA1 是否已添加到 Google Developers Console 中的同一项目中,该项目包含在字符串范围代码中传递的 Web 应用程序 CLIENT_ID。奇怪的是,如果我删除 :api_scope: 并且在我不会收到 GoogleAuthException: Unknown 之后的范围
-
面临同样的问题....你找到任何解决方案了吗???
标签: android oauth google-authentication