【问题标题】:HWIOAuthBundle facebook 443 Bad AccessHWIOAuthBundle facebook 443 访问错误
【发布时间】:2016-02-04 08:56:43
【问题描述】:

我正在构建一个 symfony REST Api,我试图让 HWIOAuthBundle、FOSUserBundle 和 LexikJWTBundle 一起工作。

我关注this gist 进行 HWIOAuthBundle/FOSUserBundle 集成。

现在我在点击 /login 路由时得到了 facebook 登录表单。但提交后我收到此错误:

[2/2] HttpTransportException: Error while sending HTTP request
[1/2] RequestException: Failed to connect to graph.facebook.com port 443: Bad access 


INFO - Matched route "hwi_oauth_service_redirect". 

CRITICAL - 
Uncaught PHP Exception HWI\Bundle\OAuthBundle\OAuth\Exception\HttpTransportException: 
"Error while sending HTTP request" 
at C:\myProject\vendor\hwi\oauth-bundle\OAuth\ResourceOwner\AbstractResourceOwner.php 
line 257 

DEBUG - 
Notified event "kernel.request" to listener
"Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke". 

...

我现在正在寻求这方面的帮助。或任何其他方式让这些捆绑包一起工作。

config.yml:

hwi_oauth:
# list of names of the firewalls in which this bundle is active, this setting MUST be set
firewall_names: [auth]

http_client:
    timeout:       10000
    verify_peer: false
    max_redirects: 1000
    ignore_errors: false

fosub:
    username_iterations: 300
    properties:
        # these properties will be used/redefined later in the custom FOSUBUserProvider service.
        facebook: facebook_id
# an optional setting to configure a query string parameter which can be used to redirect
# the user after authentication, e.g. /connect/facebook?_destination=/my/destination will
# redirect the user to /my/destination after facebook authenticates them.  If this is not
# set then the user will be redirected to the original resource that they requested, or
# the base address if no resource was requested.  This is similar to the behaviour of
# [target_path_parameter for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html).
# target_path_parameter: _destination

# an optional setting to use the HTTP REFERER header to be used in case no
# previous URL was stored in the session (i.e. no resource was requested).
# This is similar to the behaviour of
# [using the referring URL for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html#using-the-referring-url).
# use_referer: true

# here you will add one (or more) configurations for resource owners
resource_owners:
    facebook:
        type:                facebook
        client_id:           {id}
        client_secret:       {secret}
        scope:         ""
        infos_url:           "https://graph.facebook.com/me?fields=name,email,picture.type(square)"
        options:
            display: popup

security.yml:

firewalls:
     auth:
        pattern: ^/api/minisite/user/auth
        anonymous: true
        stateless: true
        form_login:
            check_path: /api/minisite/user/auth/login_check
            success_handler: lexik_jwt_authentication.handler.authentication_success
            failure_handler: lexik_jwt_authentication.handler.authentication_failure
            username_parameter: username
            password_parameter: password
            require_previous_session: false
        oauth:
            resource_owners:
                facebook:      "/api/minisite/user/auth/facebook/login/check-facebook"
            login_path:        /api/minisite/user/auth/facebook/login
            check_path: /api/minisite/user/auth/login_check
            failure_path:      /api/minisite/user/auth/facebook/login
            oauth_user_provider:
                #this is my custom user provider, created from FOSUBUserProvider - will manage the
                #automatic user registration on your site, with data from the provider (facebook. google, etc.)
                service: my_user_provider
        logout:       true
        anonymous:    true

access_control:
    - { path: ^/api/minisite/user/auth, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api/minisite, roles: IS_AUTHENTICATED_FULLY }

【问题讨论】:

  • 看来我只需要清除 facebook 开发者应用帐户中的“ip”字段。

标签: facebook symfony fosuserbundle jwt hwioauthbundle


【解决方案1】:

在您的 config.yml 文件中进行配置。

    hwi_oauth: 
        http_client: 
            verify_peer: false

设置此项允许您关闭 SSL 验证。

【讨论】:

    【解决方案2】:

    我在本地主机上使用 HWI 时遇到了同样的问题。我不知道,但如果是您的情况,请尝试将您的作品上传到服务器上。此问题的原因是您使用的是端口 80,但 facebook 需要您使用端口 443 或使用 ipv6。 希望对您有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-30
      • 1970-01-01
      • 1970-01-01
      • 2013-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多