我安装了 HWIOAuthBundle 并按照这里所说的做了一切: https ://gist.github.com/danvbe/4476697
但是当我尝试去这里时出现这个错误:“/login/google”
没有名称为“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
我已经设置了所有资源的所有者,所以我不知道为什么会出现这个错误。