src/EventListener/UserInfoListener.php
public function onFilterToken(FilterTokenEvent $event)
    {
        $token = $event->getToken();
        $service = $token->getService();
        $oauthService = $this->registry->getService($service);
        $config = $this->config[$service];

        $serviceName = OAuthServiceRegistry::getServiceName($oauthService);
        $accessToken = $oauthService->getStorage()->retrieveAccessToken($serviceName);
        $token->setAccessToken($accessToken);

        $callback = isset($config['user_callback']) && is_callable($config['user_callback']) ? $config['user_callback'] : array($this, 'defaultUserCallback');

        if (isset($config['user_endpoint'])) {
            $rawUserInfo = json_decode($oauthService->request($config['user_endpoint']), true);
        }
        call_user_func($callback, $token, $rawUserInfo, $oauthService);
    }
public function onFilterToken(FilterTokenEvent $event)
    {
        $token = $event->getToken();
        $service = $token->getService();
        $oauthService = $this->registry->getService($service);
        $config = $this->config[$service];

        $serviceName = OAuthServiceRegistry::getServiceName($oauthService);
        $accessToken = $oauthService->getStorage()->retrieveAccessToken($serviceName);
        $token->setAccessToken($accessToken);

        $callback = isset($config['user_callback']) && is_callable($config['user_callback']) ? $config['user_callback'] : array($this, 'defaultUserCallback');

        if (isset($config['user_endpoint'])) {
            $rawUserInfo = json_decode($oauthService->request($config['user_endpoint']), true);
        }
        call_user_func($callback, $token, $rawUserInfo, $oauthService);
    }
public function onFilterToken ( FilterTokenEvent $ event ) { $ token = $ event -> getToken ( ) ; $ service = $ token -> getService ( ) ; $ oauthService = $ this -> registry -> getService ( $ service ) ; $ config = $ this -> config [ $ service ] ; $ serviceName = OAuthServiceRegistry :: getServiceName ( $ oauthService ) ; $ accessToken = $ oauthService -> getStorage ( ) -> retrieveAccessToken ( $ serviceName ) ; $ token -> setAccessToken ( $ accessToken ) ; $ callback = isset ( $ config [ 'user_callback' ] ) && is_callable ( $ config [ 'user_callback' ] ) ? $ config [ 'user_callback' ] : array ( $ this , 'defaultUserCallback' ) ; if ( isset ( $ config [ 'user_endpoint' ] ) ) { $ rawUserInfo = json_decode ( $ oauthService -> request ( $ config [ 'user_endpoint' ] ) , true ) ; } call_user_func ( $ callback , $ token , $ rawUserInfo , $ oauthService ) ; }
When the security token is created, populate it with user information from the service API.

@param FilterTokenEvent $event
When the security token is created populate it with user information from the service API .