<?php
namespace App\Controller;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class SocialLoginController extends AbstractController
{
/**
* Link to this controller to start the "connect" process
*
* @Route("/connect/facebook", name="connect_facebook_start")
*/
public function connectFacebookAction(ClientRegistry $clientRegistry)
{
// will redirect to Facebook!
return $clientRegistry
->getClient('facebook_main') // key used in config/packages/knpu_oauth2_client.yaml
->redirect([
'public_profile', 'email' // the scopes you want to access
], []);
}
/**
* After going to Facebook, you're redirected back here
* because this is the "redirect_route" you configured
* in config/packages/knpu_oauth2_client.yaml
*
* @Route("/connect/facebook/check", name="connect_facebook_check")
*/
public function connectFacebookCheckAction(Request $request, ClientRegistry $clientRegistry)
{
}
/**
* @Route("/connect/google", name="connect_google_start")
*/
public function connectGoogleAction(ClientRegistry $clientRegistry)
{
return $clientRegistry
->getClient('google_main') // key used in config/packages/knpu_oauth2_client.yaml
->redirect([], []);
}
/**
* @Route("/connect/google/check", name="connect_google_check")
*/
public function connectGoogleCheckAction(Request $request, ClientRegistry $clientRegistry)
{
}
/**
* @Route("/connect/instagram", name="connect_instagram_start")
*/
public function connectInstagramAction(ClientRegistry $clientRegistry)
{
// will redirect to Facebook!
return $clientRegistry
->getClient('instagram_main') // key used in config/packages/knpu_oauth2_client.yaml
->redirect([
'user_profile' // the scopes you want to access
], []);
}
/**
* @Route("/connect/instagram/check", name="connect_instagram_check")
*/
public function connectInstagramCheckAction(Request $request, ClientRegistry $clientRegistry)
{
}
}