I’m encountering a 400: redirect_uri_mismatch error when trying to authenticate with Google OAuth2 in a Symfony application using the KnpOAuth2ClientBundle. The redirect URI being sent from my application is:
<code>http://localhost:8000/connect/google/check flowName=GeneralOAuthFlow
</code>
<code>http://localhost:8000/connect/google/check flowName=GeneralOAuthFlow
</code>
http://localhost:8000/connect/google/check flowName=GeneralOAuthFlow
However, Google does not allow whitespace in the redirect URI. The correct format should be:
<code>http://localhost:8000/connect/google/check?flowName=GeneralOAuthFlow
</code>
<code>http://localhost:8000/connect/google/check?flowName=GeneralOAuthFlow
</code>
http://localhost:8000/connect/google/check?flowName=GeneralOAuthFlow
Despite having disabled additional parameters in my configuration, I’m still seeing them appended. My configuration is as follows:
<code># config/packages/knpu_oauth2_client.yaml
knpu_oauth2_client:
clients:
google_main:
type: google
client_id: '%env(OAUTH_GOOGLE_ID)%'
client_secret: '%env(OAUTH_GOOGLE_SECRET)%'
redirect_route: connect_google_check
redirect_params: {}
</code>
<code># config/packages/knpu_oauth2_client.yaml
knpu_oauth2_client:
clients:
google_main:
type: google
client_id: '%env(OAUTH_GOOGLE_ID)%'
client_secret: '%env(OAUTH_GOOGLE_SECRET)%'
redirect_route: connect_google_check
redirect_params: {}
</code>
# config/packages/knpu_oauth2_client.yaml
knpu_oauth2_client:
clients:
google_main:
type: google
client_id: '%env(OAUTH_GOOGLE_ID)%'
client_secret: '%env(OAUTH_GOOGLE_SECRET)%'
redirect_route: connect_google_check
redirect_params: {}
- Verified that redirect_params is set to an empty array in the configuration.
- Checked for any hardcoded parameters or custom logic in my code but cant seem to find it
- Cleared browser cache and tried in incognito mode.