The android application uses Google authentication (firebase). I am receiving a notification that some users do not pass authorization. I have no idea why, because most of them are OK!
The code looks like this:
private void startSignin(){ mAuth = FirebaseAuth.getInstance(); // Check auth. if (mAuth.getCurrentUser() == null) { GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken("my_web_auth_id") .requestEmail() .build(); GoogleSignInClient mGoogleSignInClient = GoogleSignIn.getClient(this, gso); mGoogleSignInClient.signOut();// Что бы при повторной авторизации открывалось окно с выбором аккаунтов. Intent signInIntent = mGoogleSignInClient.getSignInIntent(); startActivityForResult(signInIntent, AUTH_REQUEST); } else { startMainActivity(); finish(); } } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == AUTH_REQUEST) { if (resultCode == RESULT_OK) { // результат не ок! Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { GoogleSignInAccount account = task.getResult(ApiException.class); firebaseAuthWithGoogle(account); } catch (ApiException e) { Toast.makeText(context, context.getString(R.string.auth_fail), Toast.LENGTH_LONG).show(); Crashlytics.getInstance().core.logException(e); startSignin(); } } else { Toast.makeText(context, context.getString(R.string.auth_fail), Toast.LENGTH_LONG).show(); Crashlytics.getInstance().core.logException( new Exception("onActivityResult/RESULT_CODE_FAIL/Unable Sing in with google")); // отправляю извещение. startSignin();// пробуем еще раз. } } } And I would not ask a question, but in the official tutorial no one makes a resultCode check. And I just have a problem here.
The question is: is it possible that the resultCode (specifically in this case) does not always correspond to reality and need not be used here?
Well, or what else can you do? Because judging because the error comes once, then the second time the authorization passes, well, or users immediately deleted the application.