java.lang.IllegalArgumentException: Must specify an idToken or an accessToken

I was reviewing my entire code and I found that i didn't set the requestIdToken while building GoogleSignInOptions. The correct code is:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(getString(R.string.default_web_client_id))
                    .requestEmail()
                    .build();

You need to get web client Id from your app dashboard in Firebase and paste it here.

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
               .requestIdToken("firebase_web_client_id_for_google")
               .requestEmail()
               .build();