5

I am using fosuserbundle for login and registration in my symfony 2.6 project. Now I want to allow user to login via facebook or google account.

I want to use Oauth2 library of friendsofsymfony getting from here https://packagist.org/packages/friendsofsymfony/oauth2-php

I have installed library using "friendsofsymfony/oauth2-php": "1.1.*@dev" in composer.phar and updated vendors. But I am not able to find out the documentation which can show the steps to configure and use in login.

It should work with fosuserbundle. Can anyone suggest me where can I get steps how can I use Oauth2 library in my project?

Maya Shah
  • 950
  • 7
  • 17

3 Answers3

3

You can use HWIOAuthBundle to enable login with facebook or google and many more social networks. Here is a tutorial on how to setup this bundle in your application : https://gist.github.com/danvbe/4476697

Also if you use this bundle you should check my gist : https://gist.github.com/antoinemineau/8836621#file-fosubuserprovider-php-L47, i added an if statement which prevents the code to be executed if the api are not responding as expected.

HypeR
  • 2,186
  • 16
  • 22
0

Here is example how to login via Facebook https://github.com/stfalcon-studio/lost-and-found

It uses HWIOAuthBundle + FOSUserBundle + custom user provider

You can easily add Google or any other resource owner which is present in HWIOAuthBundle. But then you also need to rewrite a bit user provider.

0

This answer is correct: https://stackoverflow.com/a/28879098/2400373

I used this manual for the integration: https://gist.github.com/danvbe/4476697

But is necesary two changes for Symfony3. First:

In the code of file: services.yml on Symfony3 is other location, the correct location is: //app/config/services.yml and change this line:

arguments: [@fos_user.user_manager,{facebook: facebook_id, google: google_id}]

for this:

arguments: ['@fos_user.user_manager',{facebook: facebook_id, google: google_id}]

Second change is in the file: //app/config/routing.yml

change this line:

pattern: /login/check-facebook

for this:

path: /login/facebook
juanitourquiza
  • 2,097
  • 1
  • 30
  • 52