Search code examples
symfonyhwioauthbundle

get resource owner name with HWIOAuthBundle


I'm working on a website with the "Sign in with Twitter" and "facebook Connect" things. So far, I can connect with both, but I'm having trouble finding the resource owner's name. I followed danvbe guide to integrate these features Great guide to implement Facebook Connect in a Symfony2 project, and found this line in the UserProvider :

$service = $response->getResourceOwner()->getName();

Obviously, I tried this simple condition :

if ($service == "facebook")

but it doesn't work. Any idea on how to get this name ?


Solution

  • nevermind, I found the solution ! To anyone wondering, you can use this :

        $service = $response->getResourceOwner()->getName();
        $user->setResourceowner($service);
        if($user->getResourceowner() === "[whatever you want, facebook, twitter, etc...]")
    

    By doing so, you can access the resource owner anywhere.