Search code examples
phpfacebooksymfonyoauthhwioauthbundle

Symfony2 - HWIOAuthBundle - Facebook login


I have followed bundle documentation configuring the HWIOAuthBundle for facebook. Then I followed this example for facebook login button display and it seems to be working, but it is not completed. I am stuck and don't know what to do next. After I press facebook login button and login to facebook I get error:

Unable to find the controller for path "/sign-in/check-facebook". The route is wrongly configured.

config.yml

hwi_oauth:
    firewall_name: hwi_oauth
    resource_owners:
        facebook:
            type:           facebook
            client_id:      "%facebook_client_id%"
            client_secret:  "%facebook_client_secret%"
            scope:          email
            options:
                display:    popup
                auth_type:  rerequest
                csrf:       true

security.yml

firewalls:
    hwi_oauth:
        pattern:    ^/
        anonymous:  ~
        oauth:
            resource_owners:
                facebook: /sign-in/check-facebook
            login_path:   /sign-in
            failure_path: /sign-in
            oauth_user_provider:
                service: oauth_user_provider

routing.yml

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

hwi_oauth_login:
    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
    prefix:   /sign-in

facebook_login:
    path: /sign-in/check-facebook

So what is this /sign-in/check-facebook needed for? Why my application can't find it? Do I have to create the controller for it?

In documentation here it is said to that information can be get through response object, but where do I write this code?


Solution

  • Have a look at your security.yml. Do you have any other firewalls that the application might be processing before your hwi_oauth firewall? It seems that @jkuri had that problem here: https://github.com/hwi/HWIOAuthBundle/issues/781#issuecomment-100468744

    His answer:

    To answer my own question... a added firewall olta_portal before main firewall... don't know where was the problem, maybe because of the same pattern ^/ in both firewalls. Working now.

    I've struggled with this issue before, too! One other sanity check is to do a php app/console debug:router | grep facebook, to verify that your route is even registered with the application in the first place.