HWIOAuth Symfony 4:服务定义必须是以“@”开头的数组或字符串,但是为servic找到字符串

问题描述 投票:0回答:1

我正在尝试在Symfony 4上集成FOS和HWIO。不幸的是,我遇到了一个错误,如下所示:

In FileLoader.php line 168:

  A service definition must be an array or a string starting with "@" but string found for service "class" in D:\web-projects\pcrmanagement\config/services.yaml. Check your YAML syntax in D:\web-projects\pcrmanagement\config/services.yaml (which is loaded in resource "D:\web-projects\pcrmanagement\config/services.yaml").


In YamlFileLoader.php line 336:

  A service definition must be an array or a string starting with "@" but string found for service "class" in D:\web-projects\pcrmanagement\config/services.yaml. Check your YAML syntax.

以下是我的代码,我将仅发布您需要查看的内容,如果您需要更多代码进行审核,我可以提供更多代码。

#config/hwi_oauth.yaml
hwi_oauth:
    firewall_names: [main]

    fosub:
        username_iterations: 30
        properties:
            googleplus: username

    resource_owners:
        google:
            type:                google
            client_id:           secret
            client_secret:       secret
            scope:               "email profile"
            options:
                csrf: true
# security.yaml
providers:
    in_memory: { memory: ~ }
    fos_userbundle:
        id: fos_user.user_provider.username
firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager

        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

        logout:    true
        anonymous: true

#services.yaml
my.oauth_aware.user_provider.service:
class: HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider
arguments: ['@fos_user.user_manager',{google: username}]

我认为他如何阅读services.yaml中的参数存在问题

fosuserbundle symfony4 hwioauthbundle
1个回答
0
投票

创建自定义user_provider并扩展HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider

然后配置自定义提供程序:

services:
    App\Security\Core\User\MyFOSUBUserProvider:
        arguments: ['@fos_user.user_manager', { facebook: facebook_id }]

然后改变:

oauth_user_provider:
   service: MyBundle\Security\Core\User\MyFOSUBUserProvider
© www.soinside.com 2019 - 2024. All rights reserved.