没有名称为“google”的资源所有者(HWIOAuthBundle& FOSUserBundle集成)

时间:2013-08-05 12:33:20

标签: php symfony oauth fosuserbundle hwioauthbundle

我安装了HWIOAuthBundle并完成了所有内容,如下所示: https://gist.github.com/danvbe/4476697

但是当我试图去这里时,我有这个错误: “/登录/谷歌”

  

没有名称为“google”的资源所有者。

我和其他API有着同样的错误:yahoo,linkedin,windows_live

我不知道为什么因为我已经完成了很好的security.yml:

jms_security_extra:
secure_all_services: false
expressions: true

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        FOS\UserBundle\Model\UserInterface: sha512

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

providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email

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

    main:
        pattern: ^/                         
        form_login:                            
            provider: fos_userbundle        
            remember_me: true                  
            csrf_provider: form.csrf_provider
            login_path: /login
            check_path: /login_check
        remember_me:
            key: %secret%                      
        anonymous: true
        logout: true                                         
        oauth:
            resource_owners:
                yahoo:              "/login/check-yahoo"
                google:             "/login/check-google"
                windows_live:       "/login/check-windows_live"
                linkedin:           "/login/check-linkedin"
            login_path:        /login
            failure_path:      /login
            oauth_user_provider:
                service: my_user_provider
        logout:
            path: /logout
            target: /
    login:
        pattern:  ^/login$
        security: false

        remember_me:
            key: "%secret%"
            lifetime: 31536000 # 365 days in seconds
            path: /
            domain: ~ # Defaults to the current domain from $_SERVER

access_control:
    - { path: ^/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/profile, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/(search|contact|myprofile), roles: ROLE_USER }

还有config.yml:

imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: "@MyprojectUserBundle/Resources/config/services.yml" }

#[..]

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Uvaluo\UserBundle\Entity\User
    registration:
        form:
            type: uvaluo_user_registration
        confirmation:
            enabled: true
            template: FOSUserBundle:Registration:email.txt.twig

hwi_oauth:
    connect:
        account_connector: my_user_provider
    firewall_name: main
    fosub:
        username_iterations: 30
        properties:
            yahoo: yahoo_id
            google: google_id
            windows_live: windows_live_id
            linkedin: linkedin_id
    resource_owners:
        any_name:
            type:                yahoo
            client_id:           X
            client_secret:       X
        any_name:
            type:                google
            client_id:           X
            client_secret:       X
            scope:               "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"    
        any_name:
            type:                windows_live
            client_id:           X
            client_secret:       X
        any_name:
            type:                linkedin
            client_id:           X
            client_secret:       X
            scope:               r_basicprofile

我已经设置了所有资源所有者,因此我不知道为什么会出现此错误。

2 个答案:

答案 0 :(得分:13)

我发现错误,我忘了用google,yahoo,linkedin,windows_live替换“any_name”

答案 1 :(得分:0)

对我来说,在security.yml中错误配置了resource_owners