没有为资源所有者'google'和'facebook'的实体定义属性

时间:2017-11-24 07:17:09

标签: facebook google-oauth symfony-3.3 hwioauthbundle

大家好我根据danvbe的要点设置了我的UserProvider(https://gist.github.com/danvbe/4476697)。但我在Facebook和谷歌都遇到了这个问题。这是我的代码: config.yml:

hwi_oauth:
connect:
    account_connector: my_user_provider
firewall_names: [main]
resource_owners:
    facebook:
        type:                facebook
        client_id:           xxxxxxxxxxxxxx
        client_secret:       xxxxxxxxxxxxx
    google:
        type:                google
        client_id:           xxxxxxxxxxxxx
        client_secret:       xxxxxxxxxxxxxxx
        scope:               "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"

fosub:
    # try 30 times to check if a username is available (foo, foo1, foo2 etc)
    username_iterations: 30

    # mapping between resource owners (see below) and properties
    properties:
        google: google_id
        facebook: facebook_id

的routing.yml

main:
        pattern:             ^/
        context:             user
        form_login:
            provider:       fos_userbundle
            login_path:     /login
            use_forward:    false
            check_path:     /login_check
            failure_path:   null
            default_target_path: list_items
            always_use_default_target_path: true
        oauth:
            resource_owners:
                facebook:           "/login/check-facebook"
                google:             "/login/check-google"
            login_path:        /login
            failure_path:      /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

和services.yml

my_user_provider:
    class: AppBundle\Entity\FOSUBUserProvider
    arguments:
        - '@fos_user.user_manager'
        - arguments: ['@fos_user.user_manager', {facebook: facebook_id, google: google_id} ]

更新当我将服务器中的参数更改为arguments: ['@fos_user.user_manager',{facebook: facebook_id, google: google_id}]时,我遇到了其他问题“无法识别的字段:facebook_id”。请帮我修理一下。谢谢大家

1 个答案:

答案 0 :(得分:0)

我使用Symfony 3.3.15,这是解决方案:
https://github.com/hwi/HWIOAuthBundle/pull/1239

仅改变:
facebookId的{​​{1}} facebook_id

googleId

更多细节: https://github.com/hwi/HWIOAuthBundle/pull/1239/commits/7f50c0cc50c16277e7545028a4e40bcc86ec5645

此致