2011-12-16 86 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