Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Plus authorization with Symfony2

We have bundles for Facebook & Twitter authorization for a Symfony2 app. But what about other sites like Google Plus? There isn't any bundle yet, and I would like to know if someone knows about the right direction to how to implement it.

I think Google Plus uses OAuth. Could it be then implemented with a OAuth bundle?

like image 373
David Morales Avatar asked Dec 16 '11 12:12

David Morales


2 Answers

KnpOAuthBundle is deprecated and recommends using HWIOAuthBundle.

HWIOAuthBundle supports several OAuth providers such as Facebook, Twitter, Google, Yahoo, etc. So you can keep all your authentication logic in 1 bundle. Usage is very easy: configure google resource owner:

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*

And add routings:

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

To start authentication process simply redirect user to /connect/*provider_name*, e.g. /connect/google

like image 171
mente Avatar answered Oct 13 '22 05:10

mente


You can check the KnpOAuthBundle (under development) - only the github OAuth provider is implemented though.

You could implemented your own Google OAuth 2.0 Provider (check this) or ask out on IRC, maybe somebody already implemented it.

like image 40
Brian Clozel Avatar answered Oct 13 '22 04:10

Brian Clozel