Search code examples
facebooksymfonyoauthhwioauthbundle

HWIOauth & Facebook get response


I have read the instructions here: https://github.com/hwi/HWIOAuthBundle/blob/master/Resources/doc/internals/response_object_and_paths.md

and have copied all the settings.

I am having trouble finding where I can get the response as shown in the instructions as:

/* @var $response \HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface */
var_dump(
    $response->getEmail(),
    $response->getProfilePicture()
);

I have overridden the ConnectController and have been playing around with it but I dont know how to access the $response given from facebook.

I have tried:

$response = $this->getResourceOwnerByName('facebook')
->getUserInformation($this->container->get('security.context')
->getToken()->getRawToken())->getResponse();

inside the connectAction() method but it doesnt seem to be working.

How can I access the response from facebook so I can grab the user profile data?

Also at what point in the life cycle of the Oautherization is this data sent?


Solution

  • Figured it out.

    I can access the $response from my user provider.

    In my particular case I have extended overiden the default FOSUserProvider and access the $response here:

    AppBundle\Security\Core\User\FOSUBUserProvider::loadUserByOAuthUserResponse()