使用Symfony2进行Google Plus授权

时间:2011-12-16 12:37:26

标签: oauth symfony google-plus

我们为Facebook&对Symfony2应用程序的Twitter授权。但是像Google Plus这样的其他网站呢?还没有任何捆绑,我想知道是否有人知道如何实施它的正确方向。

我认为Google Plus使用OAuth。是否可以使用OAuth捆绑包实现?

2 个答案:

答案 0 :(得分:8)

不推荐使用KnpOAuthBundle,建议使用HWIOAuthBundle

HWIOAuthBundle支持多个OAuth提供商,如Facebook,Twitter,Google,Yahoo等。因此,您可以将所有身份验证逻辑保存在一个捆绑包中。使用非常简单:配置谷歌资源所有者:

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

答案 1 :(得分:2)

您可以查看KnpOAuthBundle(正在开发中) - 但是只实现了github OAuth提供程序。

您可以实施自己的Google OAuth 2.0提供程序(check this)或在IRC上询问,也许某人已经实施了它。

相关问题