1

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: contact@xxxxxxxx.fr
        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.

EmmCall
  • 168
  • 1
  • 1
  • 13
  • You are confusing service definitions with configuration. Take a look at the container chapter in the docs to see the various problems you have. – Cerad Oct 02 '17 at 13:57
  • @Cerad , Excuse me but I don't understand your answer, especially that it used to work and it no longer does. – EmmCall Oct 02 '17 at 14:40
  • Nope. Not with that service definition. The answer below partially solves the issue but I'm sure you will encounter more. – Cerad Oct 02 '17 at 16:46
  • Hi @Cerad, thank you for taking the time to answer. I understand your point, but for now the solution below is working and even though I don't get everything it will perfectly do. – EmmCall Oct 03 '17 at 14:12

1 Answers1

4

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}]