Skip to content

Error 400: redirect_uri_mismatch in Google OAuth2 with Symfony and KnpOAuth2ClientBundle #451

@MikeKe254

Description

@MikeKe254

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:

http://localhost:8000/connect/google/check flowName=GeneralOAuthFlow

However, Google does not allow whitespace in the redirect URI. The correct format should be:

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:

# 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: {}
  1. Verified that redirect_params is set to an empty array in the configuration.
  2. Checked for any hardcoded parameters or custom logic in my code but cant seem to find it
  3. Cleared browser cache and tried in incognito mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions