【问题标题】:com.google.android.gms.auth.GoogleAuthException: Unknowncom.google.android.gms.auth.GoogleAuthException:未知
【发布时间】: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


【解决方案1】:

另外,请确保您的应用 ID 在 Google 开发者控制台中启用:https://console.developers.google.com/ 在 API 和身份验证、凭据、OAuth 2.0 客户端 ID、Android 客户端中。

【讨论】:

    【解决方案2】:

    对我来说,以下格式的范围有效:

    String mScope="oauth2:server:client_id:123456789-dgrgfdgfdgfdgngemhmtfko16f5tnobqphb6v.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/plus.login"
    

    此外,如果您缺少在开发者控制台中为您的应用设置的同意屏幕,您最终可能会遇到此 GoogleAuthException:未知。

    【讨论】:

    猜你喜欢
    • 2015-03-26
    • 2014-01-31
    • 2014-01-21
    • 2015-01-12
    • 2012-10-08
    • 2018-01-02
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多