本文整理汇总了PHP中HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth2ResourceOwner::getUserInformation方法的典型用法代码示例。如果您正苦于以下问题:PHP GenericOAuth2ResourceOwner::getUserInformation方法的具体用法?PHP GenericOAuth2ResourceOwner::getUserInformation怎么用?PHP GenericOAuth2ResourceOwner::getUserInformation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth2ResourceOwner
的用法示例。
在下文中一共展示了GenericOAuth2ResourceOwner::getUserInformation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetUserInformation
public function testGetUserInformation()
{
$this->markTestSkipped('Test will work from PHPUnit 3.7 onwards. See: https://github.com/sebastianbergmann/phpunit-mock-objects/issues/47.');
$this->mockBuzz($this->userResponse);
$userResponse = $this->resourceOwner->getUserInformation('access_token');
$this->assertEquals('bar', $userResponse->getUsername());
$this->assertEquals('access_token', $userResponse->getAccessToken());
}
示例2: testGetUserInformationFailure
public function testGetUserInformationFailure()
{
$exception = new RequestException();
$this->buzzClient->expects($this->once())->method('send')->will($this->throwException($exception));
try {
$this->resourceOwner->getUserInformation(array('access_token' => 'token'));
$this->fail('An exception should have been raised');
} catch (HttpTransportException $e) {
$this->assertSame($exception, $e->getPrevious());
}
}
示例3: testGetUserInformation
public function testGetUserInformation()
{
$this->mockBuzz($this->userResponse, 'application/json; charset=utf-8');
/**
* @var $userResponse \HWI\Bundle\OAuthBundle\OAuth\Response\AbstractUserResponse
*/
$userResponse = $this->resourceOwner->getUserInformation(array('access_token' => 'token'));
$this->assertEquals('1', $userResponse->getUsername());
$this->assertEquals('bar', $userResponse->getNickname());
$this->assertEquals('token', $userResponse->getAccessToken());
$this->assertNull($userResponse->getRefreshToken());
$this->assertNull($userResponse->getExpiresIn());
}
示例4: getUserInformation
/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
if ($this->options['appsecret_proof']) {
$extraParameters['appsecret_proof'] = hash_hmac('sha256', $accessToken['access_token'], $this->options['client_secret']);
}
return parent::getUserInformation($accessToken, $extraParameters);
}
示例5: getUserInformation
/**
* Override for Orcid
*
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
if (!array_key_exists('orcid', $accessToken)) {
return parent::getUserInformation($accessToken, $extraParameters);
}
$orcidService = new OrcidService();
$bio = $orcidService->getBio($accessToken["orcid"]);
$response = $this->getUserResponse();
$response->setResponse($bio);
$response->setResourceOwner($this);
$response->setOAuthToken(new OAuthToken($accessToken));
return $response;
}
示例6: getUserInformation
/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
$response = parent::getUserInformation($accessToken, $extraParameters);
$responseData = $response->getResponse();
// fetch the email addresses linked to the account
if (empty($responseData['email'])) {
$content = $this->httpRequest($this->normalizeUrl($this->options['emails_url']), null, array('Authorization: Bearer ' . $accessToken['access_token']));
foreach ($this->getResponseContent($content)['values'] as $email) {
// we only need the primary email address
if (true === $email['is_primary']) {
$responseData['email'] = $email['email'];
}
}
$response->setResponse($responseData);
}
return $response;
}
示例7: getUserInformation
/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
// SalesForce returns the infos_url in the OAuth Response Token
$this->options['infos_url'] = $accessToken['id'];
return parent::getUserInformation($accessToken, $extraParameters);
}