2011-12-16 101 views
5

我們的Facebook &授權使用Symfony2應用程序的Twitter授權。但是Google Plus等其他網站呢?目前還沒有任何軟件包,我想知道是否有人知道如何實施它的正確方向。Google Plus授權使用Symfony2

我認爲Google Plus使用OAuth。那麼它是否可以通過OAuth包實現?

回答

2

您可以檢查KnpOAuthBundle(開發中) - 只有github上的OAuth提供者,雖然實現。

你可以實現你自己的谷歌的OAuth 2.0提供商(check this)或問出來的IRC,也許有人已經付諸實施。

8

KnpOAuthBundle已過時,建議使用HWIOAuthBundle

HWIOAuthBundle支持多種OAuth供應商,如Facebook,Twitter,谷歌,雅虎等,所以你可以保持您所有的認證邏輯在1束。用法很簡單:谷歌配置資源所有者:

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* 

並添加路由:

google_login: 
    pattern: /login/google 
hwi_oauth_redirect: 
    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml" 
    prefix: /connect 

要開始認證過程簡單重定向用戶/connect/*provider_name*,例如/connect/google