There is no license information available for the latest version (dev-master) of this package.

dev-master / 0.1.x-dev 2014-03-17 04:34 UTC

This package is auto-updated.

Last update: 2024-07-12 02:50:12 UTC


With this bundle, you can request an access token on your api (that uses FOSOAuthServerBundle) against a facebook access token. This bundle will check that the facebook access token is valid, and get the fb_id of the user.

For example: you have an iOS app that needs a token to authenticate a user against your api, but you want to only show the Facebook SSO authentication to your user.


Add the bundle to your AppKernel

class AppKernel extends Kernel
    public function registerBundles()
            $bundles = array(
                new AdrienBrault\OAuth2FacebookGrantBundle\ABOAuth2FacebookGrantBundle(),

Configure the bundle:

    user_provider: bundle.facebook_user_provider
    uri: ""

And implement your bundle.facebook_user_provider like this:


namespace AdrienBrault\Core\UserBundle\Security;

use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;

use FSC\Core\UserBundle\Manager\UserManager;

class FacebookUserProvider implements UserProviderInterface
    protected $userManager;

    public function __construct(UserManager $userManager)
        $this->userManager = $userManager;

    public function loadUserByUsername($facebookId)
        $userRepository = $this->userManager->getRepository();

        return $userRepository->findOneBy(array(
            'facebookID' => $facebookId,

    public function refreshUser(UserInterface $user)
        $class = get_class($user);
        if (!$this->supportsClass($class)) {
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $class));

        return $this->loadUserByUsername($user->getFacebookID());

    public function supportsClass($class)
        return $this->userManager->supportsClass($class);


Endpoint: /oauth/v2/token by default


 - client_id
 - client_secret
 - facebook_access_token


$ curl -XGET "http://youapi/oauth/v2/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&"
    "access_token": "krXC75SKp--cISB_fqHA4aSsviyDVJwuutiWgaM",
    "expires_in": 604800,
    "token_type": "bearer",
    "scope": null,
    "refresh_token": "mnFs3VsGIF87x6VIazAz5ftvYw7VTfRqoBSqNCY"