I want to implement signing in to my application using a Google account. I use Firebase to authenticate the user.
I've already read the documentation like million times. I've added SH1 debug key to Firebase project as a fingerprint and I use Web SDK configuration from the Firebase as a web client id:

I've got it set up in strings.xml file
<string name="web_client_id">**HERE**</string>
the rest of my code looks like this:
public class AuthFragment extends Fragment {
private FragmentAuthBinding binding;
private SignInClient oneTapClient;
ActivityResultLauncher<Intent> oneTapLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
result -> {
if (result.getResultCode() == Activity.RESULT_OK) {
Intent data = result.getData();
try {
var credential = oneTapClient.getSignInCredentialFromIntent(data);
String idToken = credential.getGoogleIdToken();
} catch (ApiException e) {
throw new RuntimeException(e);
}
}
});
public AuthFragment() {}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentAuthBinding.inflate(inflater, container, false);
return binding.getRoot();
}
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
HandleGoogleLogin();
}
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
void HandleGoogleLogin()
{
oneTapClient = Identity.getSignInClient(requireActivity());
var signInRequest = BeginSignInRequest.builder()
.setGoogleIdTokenRequestOptions(BeginSignInRequest.GoogleIdTokenRequestOptions.builder()
.setSupported(true)
.setServerClientId(getString(R.string.web_client_id))
.setFilterByAuthorizedAccounts(false)
.build())
.build();
var googleLoginButton = binding.googleLoginButton;
googleLoginButton.setOnClickListener(v -> {
oneTapClient.beginSignIn(signInRequest)
.addOnSuccessListener(requireActivity(), result -> {
var intentSenderRequest = new IntentSenderRequest
.Builder(result.getPendingIntent().getIntentSender())
.build();
oneTapLauncher.launch(intentSenderRequest.getFillInIntent());
})
.addOnFailureListener(requireActivity(), e -> {
Log.d("googleLoginButton", "oneTapClient.beginSignIn:onError - " + e.getMessage());
// Handle errors or continue presenting the signed-out UI
});
});
}
}
this is not the only way I've tried to implement it. I've also tried adding sh1 key to https://console.cloud.google.com/ and configuring OAuth 2.0 from the https://console.cloud.google.com/apis/credentials?project=myproject site:
but nothing actually works.
All I always get is Log.d("googleLoginButton", "oneTapClient.beginSignIn:onError - " + e.getMessage()); -> Cannot find a matching credential.
I don't know what I do wrong. Note that I've got setFilterByAuthorizedAccounts set to false.
How can I make it work? What do I do wrong?
I've already read:
Getting "16: Cannot find a matching credential" when doing One Tap sign-in and sign-up on Android
Firebase Google auth, signing out and logging in again will log in with the last signed account
Google Firebase sign out and forget user in Android app
nothing helps.
