-1

我正在使用HWIOAuthBundle Symfony2 Bundle,并按照本指南中的步骤配置并运行 Bundle,但出现此错误:

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

我如何解决这个问题?

额外信息

hwioauth.yml(包含在 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

路线在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 部分位于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 
4

2 回答 2

1

请点击此链接HwiOAuthBundle。请在为网络创建应用程序时正确指定重定向 URI。

如果您使用 facebook:无需提及重定向 URI。在使用 google 时,我们必须正确指定重定向 URI。

请关注HwiOAuthBundle 文档,如果您发现任何错误,请告诉我。

于 2014-05-06T03:04:40.720 回答
0

如果它可以帮助某人,我在这篇文章中找到了解决方案:

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

我没有在 Github 应用程序中选择正确的 url 作为回调。如果我们遵循文档,它必须是 /login/check-github。

于 2016-07-12T09:30:34.243 回答