src/Kunstmaan/AdminBundle/Security/OAuthAuthenticator.php
public function getUser($credentials, UserProviderInterface $userProvider)
    {
        $idToken = $credentials['token'];

        $gc = new \Google_Client();
        $gc->setClientId($this->clientId);
        $gc->setClientSecret($this->clientSecret);
        $ticket = $gc->verifyIdToken($idToken);
        if (!$ticket instanceof \Google_LoginTicket) {
            return null;
        }

        $data = $ticket->getAttributes()['payload'];
        $email = $data['email'];
        $googleId = $data['sub'];

        return $this->oAuthUserCreator->getOrCreateUser($email, $googleId);
    }
public function getUser($credentials, UserProviderInterface $userProvider)
    {
        $idToken = $credentials['token'];

        $gc = new \Google_Client();
        $gc->setClientId($this->clientId);
        $gc->setClientSecret($this->clientSecret);
        $ticket = $gc->verifyIdToken($idToken);
        if (!$ticket instanceof \Google_LoginTicket) {
            return null;
        }

        $data = $ticket->getAttributes()['payload'];
        $email = $data['email'];
        $googleId = $data['sub'];

        return $this->oAuthUserCreator->getOrCreateUser($email, $googleId);
    }
public function getUser ( $ credentials , UserProviderInterface $ userProvider ) { $ idToken = $ credentials [ 'token' ] ; $ gc = new \ Google_Client ( ) ; $ gc -> setClientId ( $ this -> clientId ) ; $ gc -> setClientSecret ( $ this -> clientSecret ) ; $ ticket = $ gc -> verifyIdToken ( $ idToken ) ; if ( ! $ ticket instanceof \ Google_LoginTicket ) { return null ; } $ data = $ ticket -> getAttributes ( ) [ 'payload' ] ; $ email = $ data [ 'email' ] ; $ googleId = $ data [ 'sub' ] ; return $ this -> oAuthUserCreator -> getOrCreateUser ( $ email , $ googleId ) ; }
Return a UserInterface object based on the credentials.

The *credentials* are the return value from getCredentials()

You may throw an AuthenticationException if you wish. If you return
null, then a UsernameNotFoundException is thrown for you.

@param mixed                 $credentials
@param UserProviderInterface $userProvider

@throws AuthenticationException

@return UserInterface|null
Return a UserInterface object based on the credentials .