KnpOAuthBundle không được dùng nữa và khuyên bạn nên sử dụng HWIOAuthBundle.
HWIOAuthBundle hỗ trợ một số nhà cung cấp OAuth như Facebook, Twitter, Google, Yahoo, v.v. Vì vậy, bạn có thể giữ tất cả logic xác thực của mình trong 1 gói. Cách sử dụng rất đơn giản: chủ sở hữu cấu hình tài nguyên google:
hwi_oauth:
resource_owners:
google:
type: google
client_id: *client_id*
client_secret: *client_secret
scope: "https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
firewall_name: *main firewal name*
Và thêm tuyến đường:
google_login:
pattern: /login/google
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /connect
Để bắt đầu quá trình xác thực chỉ cần chuyển hướng người dùng đến /connect/*provider_name*
, ví dụ /connect/google