Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.google.android.gms.auth.GoogleAuthException: Unknown

I am trying to use Oauth2 to authenticate the google user logged in my device. I have created the client ID but I am not able to get the expected result.

Code is:

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;
    }

Error is:

com.google.android.gms.auth.GoogleAuthException: Unknown

Help much appreciated.

Thank you.

like image 285
PramodK Avatar asked Aug 05 '14 05:08

PramodK


Video Answer


1 Answers

For me the below format of scope worked:

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

Along with this if you are missing the Consent Screen set up in the Developers console for your app you might end up with this GoogleAuthException: Unknown.

like image 115
PramodK Avatar answered Oct 17 '22 21:10

PramodK