Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sign In error: Status Code: SIGN_IN_REQUIRED when signing in with Google on android

Everytime I try to login with Google API, I get the following error. My manifest has the appropriate permissions and I did create my credentials accordingly. So I don't know what the problem is. The consent screen doesn't show either.

com.omer.notetoself D/NTS:﹕ ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{3678d5c: android.os.BinderProxy@19bcbe30}, message=null}

  package com.omer.notetoself;

    import android.app.Activity;
    import android.content.Intent;
    import android.content.IntentSender;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;

    import com.google.android.gms.common.ConnectionResult;
    import com.google.android.gms.common.Scopes;
    import com.google.android.gms.common.api.GoogleApiClient;
    import com.google.android.gms.common.api.Scope;
    import com.google.android.gms.plus.Plus;


     `public class Activity_Login extends Activity implements View.OnClickListener,GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener{` 


    private static final int RC_SIGN_IN = 0;
    private GoogleApiClient mGoogleApiClient;
    /* Is there a ConnectionResult resolution in progress? */
    private boolean mIsResolving = false;

    /* Should we automatically resolve ConnectionResults when possible? */
    private boolean mShouldResolve = false;


    EditText editText_userName;
    EditText editText_password;

    Button button_facebook_login;
    Button button_google_login;
    Button button_login;
    Button button_signUp;

    String userName;
    String password;

    @Override
    protected void onStop() {
        super.onStop();
        mGoogleApiClient.disconnect();
    }

    @Override
    protected void onStart() {
        super.onStart();
        mGoogleApiClient.connect();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        editText_userName = (EditText)findViewById(R.id.editText_username);
        editText_password = (EditText)findViewById(R.id.editText_password);
        button_login = (Button)findViewById(R.id.button_login);
        button_facebook_login = (Button)findViewById(R.id.button_facebook);
        button_google_login = (Button)findViewById(R.id.button_google);

        button_signUp = (Button)findViewById(R.id.button_signup);
        button_login.setOnClickListener(this);
        button_signUp.setOnClickListener(this);
        button_facebook_login.setOnClickListener(this);
        button_google_login.setOnClickListener(this);


        //GOOGLE+ API

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Plus.API)
                .addScope(new Scope(Scopes.PROFILE))
                .addScope(new Scope(Scopes.EMAIL))
                .build();
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_activity_login, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.button_login: //AUTHENTICATE PARSE
                userName = editText_userName.getText().toString().trim();
                password = editText_password.getText().toString().trim();
                AppUtilities.parseLogin(this, userName, password);
                break;
            case R.id.button_signup: //LAUNCH SIGN UP ACTIVITY
                Intent intent = new Intent(
                        Activity_Login.this,
                        Activity_SignUp.class);
                startActivity(intent);
                break;
            case R.id.button_facebook:

                AppUtilities.facebookLogin(this);
                break;
            case R.id.button_google:
                initGoogle();



                break;

        }

    }

    public void initGoogle(){
        mGoogleApiClient.connect();
    }

    @Override
    public void onConnected(Bundle bundle) {
        String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
        AppUtilities.googleLogin(this,email);
    }

    @Override
    public void onConnectionSuspended(int i) {

    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
        AppUtilities.log(connectionResult.toString());


        if (!mIsResolving && mShouldResolve) {
            if (connectionResult.hasResolution()) {
                try {
                    connectionResult.startResolutionForResult(this, RC_SIGN_IN);
                    mIsResolving = true;
                } catch (IntentSender.SendIntentException e) {
                    Log.e(AppUtilities.TAG, "Could not resolve ConnectionResult.", e);
                    mIsResolving = false;
                    mGoogleApiClient.connect();
                }
            } else {
                // Could not resolve the connection result, show the user an
                // error dialog.
                //showErrorDialog(connectionResult);
            }
        } else {
            // Show the signed-out UI
            //showSignedOutUI();
        }
    }
}
like image 596
Omer Ozer Avatar asked Sep 20 '25 07:09

Omer Ozer


1 Answers

Make sure SHA-1 signing-certificate fingerprint of your app in google developers console belong to the same key which is used to sign APK you are testing.

By default, when assembling debug build Android Studio use own debug key. You can change it through right-clicking on the app and selecting "Open Module Settings". Go to "Signing" tab and configure the same key you have mentioned in dev console. After that navigate to the "Build Types" tab and select your signing configuration.

like image 107
George Keeper Avatar answered Sep 21 '25 21:09

George Keeper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!