Google login uses same account everytime users login

前端 未结 13 1800
无人共我
无人共我 2020-12-09 11:22

I use OAuth to let users sign in to the android app via Google account. When the user taps the Google login button for the first time, it produces a dialog to choose the acc

13条回答
  •  一生所求
    2020-12-09 12:21

    Just add mGoogleSignInClient.signOut(); After succesfully handling sign in.

    private void handleSignInResult(Task completedTask) {
        try {
            GoogleSignInAccount account = completedTask.getResult(ApiException.class);
            AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
            mAuth.signInWithCredential(credential).addOnCompleteListener(this, task -> {
                if(task.isSuccessful()) {
                    mGoogleSignInClient.signOut();
                    updateUI();
                } else {
                    Toast.makeText(this, "Something went wrong.", Toast.LENGTH_SHORT).show();
                }
            });
        } catch (ApiException e) {
            Log.w("SignIn Failed", "signInResult:failed code=" + e.getStatusCode());
            updateUI(null);
        }
    }
    

提交回复
热议问题