Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

G+ signin on android throws INVALID_CLIENT_ID

I am trying to implement G+ sign in, in our app, however, despite having repeatedly updating the client id, and recreating a new one as well, I keep on getting an error saying

I/GLSUser﹕ GLS error: INVALID_CLIENT_ID [email protected] oauth2:https://www.googleapis.com/auth/plus.login

Not sure what's wrong. I can see the account list popup, and everything else seems to work as well. I have double checked my client id as well.

[EDIT]

Here is the code I am using

    private void getGoogleAccessToken() {
        Bundle appActivities = new Bundle();
        appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "AddActivity BuyActivity");
        String scopes = "oauth2:server:client_id:number-randomness.apps.googleusercontent.com" + ":api_scope:"+ Scopes.PLUS_LOGIN;
        mGoogleToken = null;

        try {
            mGoogleToken = GoogleAuthUtil.getToken(this, mPlusClient.getAccountName(), scopes, appActivities);
        } catch (IOException transientEx) {
            // network or server error, the call is expected to succeed if you try again later.
            // Don't attempt to call again immediately - the request is likely to
            // fail, you'll hit quotas or back-off.
            Crouton.makeText(this, R.string.google_bad_boy, Style.ALERT).show();
        } catch (UserRecoverableAuthException e) {
            // Recover
            Crouton.makeText(this, R.string.google_bad_boy, Style.ALERT).show();
        } catch (GoogleAuthException authEx) {
            // Failure. The call is not expected to ever succeed so it should not be
            // retried.
            Crouton.makeText(this, R.string.google_not_allow_login, Style.ALERT).show();
        } catch (Exception e) {
            Crouton.makeText(this, R.string.google_not_allow_login, Style.ALERT).show();
//          throw new RuntimeException(e);
        }
    }

[EDIT 2]

Seemingly I an getting a not successful result for Activity in this code:

    mGoogleButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!mPlusClient.isConnected()) {
                    mConnectionProgressDialog.show();
                    if (mConnectionResult != null) {
                        try {
                            mConnectionResult.startResolutionForResult(SplashActivity.this, REQUEST_CODE_RESOLVE_ERR);
                        } catch (IntentSender.SendIntentException e) {
                            // Try connecting again.
                            mPlusClient.connect();
                        }
                    } else {
                        mPlusClient.connect();
                    }
                }
            }
        });
like image 362
Amit Avatar asked Dec 02 '22 20:12

Amit


1 Answers

Make sure you've updated your details on the Consent Screen in your project settings in the Google Developer console. You need to confirm your (developer) email address, and provide a name for your app which will be displayed to the user in the permissions confirmation screen.

While the Google+ QuickStart guide (https://developers.google.com/+/quickstart/android) doesn't talk about this explicitly, you need to do this (very simple), else you'll get an INVALID_CLIENT_ID error on your device.

like image 103
PacificSky Avatar answered Dec 27 '22 02:12

PacificSky