protected function createOrUpdateAccount($token, $tokenSecret) {
		$uri = new Uri('https://api.twitter.com/1.1/account/verify_credentials.json');
		$request = Request::create($uri, 'GET');
		$request = $this->requestSignatureGenerator->signRequest($request);
		$request->setHeader('Content-Type', 'application/x-www-form-urlencoded', TRUE);

		$response = $this->requestEngine->sendRequest($request);
		$userData = json_decode($response->getContent(), TRUE);

		/** @var $account Account */
		$account = NULL;
		$providerName = $this->name;
		$accountRepository = $this->accountRepository;
		$this->securityContext->withoutAuthorizationChecks(function () use ($userData, $providerName, $accountRepository, &$account) {
			$account = $accountRepository->findByAccountIdentifierAndAuthenticationProviderName($userData['screen_name'], $providerName);
		});
		if ($account === NULL) {
			$defaultRole = $this->policyService->getRole('Flowpack.TwitterApi:AuthenticatedUser');
			$account = new Account();
			$account->setAccountIdentifier($userData['screen_name']);
			$account->setAuthenticationProviderName($providerName);
			$account->addRole($defaultRole);
			$this->accountRepository->add($account);
		}

		$account->setCredentialsSource($token . '&' . $tokenSecret);
		$this->accountRepository->update($account);
		$this->persistenceManager->whitelistObject($account);
		return $account;
	}
protected function createOrUpdateAccount($token, $tokenSecret) {
		$uri = new Uri('https://api.twitter.com/1.1/account/verify_credentials.json');
		$request = Request::create($uri, 'GET');
		$request = $this->requestSignatureGenerator->signRequest($request);
		$request->setHeader('Content-Type', 'application/x-www-form-urlencoded', TRUE);

		$response = $this->requestEngine->sendRequest($request);
		$userData = json_decode($response->getContent(), TRUE);

		/** @var $account Account */
		$account = NULL;
		$providerName = $this->name;
		$accountRepository = $this->accountRepository;
		$this->securityContext->withoutAuthorizationChecks(function () use ($userData, $providerName, $accountRepository, &$account) {
			$account = $accountRepository->findByAccountIdentifierAndAuthenticationProviderName($userData['screen_name'], $providerName);
		});
		if ($account === NULL) {
			$defaultRole = $this->policyService->getRole('Flowpack.TwitterApi:AuthenticatedUser');
			$account = new Account();
			$account->setAccountIdentifier($userData['screen_name']);
			$account->setAuthenticationProviderName($providerName);
			$account->addRole($defaultRole);
			$this->accountRepository->add($account);
		}

		$account->setCredentialsSource($token . '&' . $tokenSecret);
		$this->accountRepository->update($account);
		$this->persistenceManager->whitelistObject($account);
		return $account;
	}
protected function createOrUpdateAccount ( $ token , $ tokenSecret ) { $ uri = new Uri ( 'https://api.twitter.com/1.1/account/verify_credentials.json' ) ; $ request = Request :: create ( $ uri , 'GET' ) ; $ request = $ this -> requestSignatureGenerator -> signRequest ( $ request ) ; $ request -> setHeader ( 'Content-Type' , 'application/x-www-form-urlencoded' , TRUE ) ; $ response = $ this -> requestEngine -> sendRequest ( $ request ) ; $ userData = json_decode ( $ response -> getContent ( ) , TRUE ) ; /** @var $account Account */ $ account = NULL ; $ providerName = $ this -> name ; $ accountRepository = $ this -> accountRepository ; $ this -> securityContext -> withoutAuthorizationChecks ( function ( ) use ( $ userData , $ providerName , $ accountRepository , & $ account ) { $ account = $ accountRepository -> findByAccountIdentifierAndAuthenticationProviderName ( $ userData [ 'screen_name' ] , $ providerName ) ; } ) ; if ( $ account === NULL ) { $ defaultRole = $ this -> policyService -> getRole ( 'Flowpack.TwitterApi:AuthenticatedUser' ) ; $ account = new Account ( ) ; $ account -> setAccountIdentifier ( $ userData [ 'screen_name' ] ) ; $ account -> setAuthenticationProviderName ( $ providerName ) ; $ account -> addRole ( $ defaultRole ) ; $ this -> accountRepository -> add ( $ account ) ; } $ account -> setCredentialsSource ( $ token . '&' . $ tokenSecret ) ; $ this -> accountRepository -> update ( $ account ) ; $ this -> persistenceManager -> whitelistObject ( $ account ) ; return $ account ; }
check for an existing user account and either return that or create a fresh account for the authenticated user.

@param string $token
@param string $tokenSecret
@return Account
check for an existing user account and either return that or create a fresh account for the authenticated user .