Error: redirect_uri_mistmatch after get Bundle configured and try to login using Github application

StackOverflow https://stackoverflow.com/questions/23485168

  •  16-07-2023
  •  | 
  •  

質問

I'm using HWIOAuthBundle Symfony2 Bundle and I follow the steps on this guide to get the Bundle configured and working but I get this error:

error=redirect_uri_mismatch
error_description=The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application

How I fix this?

Extra info

hwioauth.yml (included in config.yml)

hwi_oauth:
    firewall_name: secure
    connect:
        confirmation: true
    resource_owners:
        github:
            type:                github
            client_id:           "%github_app_id%"
            client_secret:       "%github_app_secret%"
            scope:               "user:email"
    fosub:
            # try 30 times to check if a username is available (foo, foo1, foo2 etc)
            username_iterations: 30

            # mapping between resource owners (see below) and properties
            properties:
                github: githubID

Routes at routing.yml

#HWIOAuthBundle
hwi_oauth_redirect:
    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
    prefix:   /secure/connect

hwi_oauth_login:
    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
    prefix:   /secure/connect

hwi_oauth_connect:
    resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
    prefix:   /secure/connect

hwi_github_login:
    prefix: /secure/check-github

HWIOAuth part at security.yml

secure:
        pattern: ^/secure
        oauth:
            failure_path: /secure/connect
            login_path: /secure/connect
            check_path: /secure/connect
            provider: fos_userbundle
            resource_owners:
                github: "/secure/check-github"
            oauth_user_provider:
                service: hwi_oauth.user.provider.fosub_bridge

        anonymous:    true
        logout:
            path:           /secure/logout
            target:         /secure/connect #where to go after logout

access_control:
    - { path: ^/secure/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/secure/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/secure, roles: ROLE_USER 
役に立ちましたか?

解決

Please follow this link HwiOAuthBundle. Please specify the redirect URI properly while creating app for the network.

If you used facebook: No need to mention the redirect URI. While working with google we have to specify the redirect URI properly.

Please follow HwiOAuthBundle documentation and let me know If you found any error.

他のヒント

I found the solution on this post if it can help someone:

https://github.com/hwi/HWIOAuthBundle/issues/532

I didn't selected the right url as callback in the Github app. It must be /login/check-github if we follow the documentation.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top