Search code examples
phpsymfonyhwioauthbundlesymfony-2.6

ServiceNotFoundException: HWIOAuthBundle + Salesforce resource owner


I am trying to get HWIOAuthBundle the bundle installed & configured but I am having some issues. This is what I have done:

1) Enable the bundle at AppKernel.php:

new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),

2) Add this line to the config.yml:

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: sonata.yml }
    - { resource: hwi.yml }

3) Write the following at hwi.yml file:

hwi_oauth:
    firewall_name: admin_area

    resource_owners:
        salesforce:
            type:             salesforce
            client_id:        <cliend_id> 
            client_secret:    <client_secret>

4) Add the routes at the very beginning at routing.yml:

#FOSUserBundle
fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

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

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

#SonataAdmin
admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix: /admin

_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /admin

When I call at browser: http://applocal.dev/app_dev.php I got this error:

ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58: The service "hwi_oauth.security.oauth_utils" has a dependency on a non-existent service "hwi_oauth.resource_ownermap.admin_area".

What I am missing here? Why is that error?


Solution

  • looks like you didn't configured oauth firwall

    Pls check that you have at app/config/security.yml something like:

    security:
        firewalls:
            admin_area:
                anonymous: ~
                oauth:
                    resource_owners:
                        facebook:           "/login/check-facebook"
                        google:             "/login/check-google"
                        my_custom_provider: "/login/check-custom"
                        my_github:          "/login/check-github"
                    login_path:        /login
                    use_forward:       false
                    failure_path:      /login
    
                    oauth_user_provider:
                        service: my.oauth_aware.user_provider.service
    
        access_control:
            - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }