com.google.android.gms.auth.GoogleAuthException:未知

Pra*_*odK 10 android oauth google-authentication

我正在尝试使用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;
    }
Run Code Online (Sandbox Code Playgroud)

错误是:

com.google.android.gms.auth.GoogleAuthException: Unknown
Run Code Online (Sandbox Code Playgroud)

非常感谢.

谢谢.

Pra*_*odK 2

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

String mScope="oauth2:server:client_id:123456789-dgrgfdgfdgfdgngemhmtfko16f5tnobqphb6v.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/plus.login"
Run Code Online (Sandbox Code Playgroud)

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