0

我正在使用 HWIOAuthBundle 通过 oauth 创建用户。

第一次连接一切正常时,我创建了用户并在现场正确地进行了重定向:http://localhost/rememberme/web/app_dev.php/login/check-google

从我第二次与谷歌连接更多时返回我一个错误:

Error:redirect_uri_mismatch
The redirect URI in the request: http://localhost/rememberme/web/app_dev.php/oauth/connect/service/google did not match a registered redirect URI

cookie_policy_enforce=false
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
response_type=code
access_type=online
redirect_uri=http://localhost/rememberme/web/app_dev.php/oauth/connect/service/google
display=page
client_id= *****

看来,一旦您是注册用户,就会更改重定向的链接。

为什么会这样?

有没有可能解决?

编辑

这是我的配置:

安全.yml:

firewalls:
    main:
        pattern: ^/
        oauth:
            resource_owners:
                facebook: "/login/check-facebook"
                google: "/login/check-google"
            login_path:        /login
            failure_path:      /login
            default_target_path: acme_user_default_index
            oauth_user_provider:
                    service: hwi_oauth.user.provider.fosub_bridge
        form_login:
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
            default_target_path: acme_user_default_index
            remember_me: true
        logout:       true
        anonymous:    true
        remember_me:
            key: %secret%
            lifetime: 31536000 # 365 days in seconds
            path: /
            domain: ~
            always_remember_me: true

配置.yml:

hwi_oauth:
connect:
    confirmation: true
firewall_name: main
resource_owners:
    facebook:
        type:                facebook
        client_id:           %oauth.facebook.client_id%
        client_secret:       %oauth.facebook.client_secret%
        scope:         "email"
        infos_url:     "https://graph.facebook.com/me?fields=username,name,email,picture.type(square)"
        paths:
            email:          email
            profilepicture: picture.data.url
        options:
            display: popup
    google:
        type:   google
        client_id:          %oauth.google.client_id%
        client_secret:      %oauth.google.client_secret%
        scope:              "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
        paths:
            email:           email
            profilepicture:  picture
fosub:
    username_iterations: 5
    properties:
        facebook: facebookId
        google: googleId
4

3 回答 3

0

您应该添加 redirect_uri

https://console.developers.google.com/project/[your_project_name]/apiui/credential中重定向 URI

于 2014-05-10T03:43:20.947 回答
0

您可以在您的 Google Apps 凭据中放置多个重定向 redirect_uri。!不要创建新的客户 ID!

只需编辑当前客户端的设置,然后在新行的第一个下面(在文本区域中)添加一个 redirect_uri。

我有同样的问题,这解决了它

于 2014-07-02T19:22:26.417 回答
0

您有两个不同的 url:第一个,在 security.yml 中的 oauth.resource_owners 下定义,在用户未登录时调用,第二个在用户已登录时调用。

逻辑在OAuthUtils->getAuthorizationUrl()中完成

不幸的是,当您已登录时,似乎无法覆盖重定向 url,因此您必须http://HOST/app[_dev].php/login/service/facebook在 Google 开发者控制台中添加第二个“授权重定向 URI”。

于 2016-03-24T14:31:16.317 回答