Unable to integrate Keycloak with any identity provider

I used this tutorial to set up keycloak with google: https://keycloakthemes.com/blog/how-to-setup-sign-in-with-google-using-keycloak

I can see the google sign-on on my login page, but when clicking it I get an invalid request message. My logs look like this:

21:48:03,440 WARN  [org.keycloak.events] (default task-107) type=IDENTITY_PROVIDER_LOGIN_ERROR, realmId=myRealm, clientId=null, userId=null, ipAddress=xxxx, error=invalidRequestMessage, identity_provider=google
02:07:59,598 ERROR [org.keycloak.services.resources.IdentityBrokerService] (default task-120) invalidRequestMessage
02:07:59,608 ERROR [org.keycloak.services.resources.IdentityBrokerService] (default task-120) unexpectedErrorHandlingRequestMessage: javax.ws.rs.WebApplicationException: HTTP 400 Bad Request

I went through the keycloak stack trace and saw that the client_id is provided by an API endpoint in IdentityBrokerService#performLogin so I can’t really debug further to find out why the client_id is null but the realm is not.

I tried to set it up with github too and got the same error, so I don’t believe it’s related to the google app I created. I’ve scoured online and seen people with similar issues, but no helpful resolution.

This ended up being an issue with how I was handling my routing–when redirecting to the broker endpoint the query params weren’t being passed along.

So how did you solve this exactly? I seem to have a similar issue, but only for a few users so it’s really hard to pinpoint what the actual cause of the issue is.