Search code examples
phpsymfonyfosuserbundlehwioauthbundle

Symfony 3.3 ( HWIOAuthBundle + FOSUserBundle) Invalid key "user_manager" found in arguments


I've just updated to Symfony 3.3 and now I get that error message :

Invalid key "user_manager" found in arguments of method "__construct()" for service "app.fos_user.oauth_provider": only integer or $named arguments are allowed.

I don't understand the reason for that issue, here is my configuration :

service.yml # app/config/service.yml

app.fos_user.oauth_provider:
        class: EC\UserBundle\Entity\FOSUBUserProvider
        arguments:
            user_manager: "@fos_user.user_manager"
            user_response:
                facebook: facebook_id

config.yml

# app/config/config.yml

# FOSUserBundle Configuration
fos_user:
    db_driver: orm 
    firewall_name: main 
    user_class: EC\UserBundle\Entity\User 
    use_username_form_type: false

    registration:
        form:
            type: EC\UserBundle\Form\RegistrationType
    profile:
        form:
            type: EC\UserBundle\Form\ProfileFormType

    from_email:
        address: [email protected]
        sender_name: xxxxxxxxx

#HWIOAuthBundle
hwi_oauth:
    firewall_names: ["main"]
    fosub:
        username_iterations: 30
        properties:
            facebook: facebook_id
    resource_owners:

        facebook:
            type:           facebook
            client_id:      "%facebook_client_id%"
            client_secret:  "%facebook_secret%"
            scope:         email
            infos_url:     "https://graph.facebook.com/me?fields=id,email,gender,last_name,first_name,birthday,picture.type(square)"
            options:
                crsf: true

security.yml

# app/config/security.yml
security:

    encoders:
        EC\UserBundle\Entity\User: sha512

    role_hierarchy:
        ROLE_ADMIN: ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWER_TO_SWITCH]


    providers:
        main:
            id: fos_user.user_provider.username_email

    firewalls:

        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            pattern: ^/
            anonymous: true

            provider: main

            form_login: 
                login_path: fos_user_security_login
                check_path: fos_user_security_check

            logout:
                path: fos_user_security_logout
                target: /

            remember_me:
                secret: %secret% 

            #HWIOAuthBundle
            oauth:
                resource_owners:
                    facebook: "/connect/check-facebook"

                login_path:     /login
                failure_path:   /login

                oauth_user_provider:
                    service: app.fos_user.oauth_provider

Before everything worked well.

Thank you for helping me.


Solution

  • Your service is not well-organized since you should pass as arguments fos.user_manager service, and facebook.

    Try to edit the user provider in your service.yml to be something like:

    hwi_oauth.user.provider.entity:
        class: EC\UserBundle\Entity\FOSUBUserProvider
        #this is the place where the properties are passed to the UserProvider - see config.yml
        arguments: ['@fos_user.user_manager',{facebook: facebook_id}]