本文整理汇总了PHP中League\OAuth2\Client\Provider\AbstractProvider::getResourceOwner方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractProvider::getResourceOwner方法的具体用法?PHP AbstractProvider::getResourceOwner怎么用?PHP AbstractProvider::getResourceOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\OAuth2\Client\Provider\AbstractProvider
的用法示例。
在下文中一共展示了AbstractProvider::getResourceOwner方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResourceOwner
/**
* Query the provider for the resource owner.
*
* @param AccessToken $accessToken
*
* @throws IdentityProviderException
*
* @return ResourceOwnerInterface
*/
protected function getResourceOwner(AccessToken $accessToken)
{
if ($this->resourceOwner === null) {
$this->resourceOwner = $this->provider->getResourceOwner($accessToken);
}
return $this->resourceOwner;
}
示例2: makeRegistrationRequest
protected function makeRegistrationRequest(AbstractProvider $provider, AccessToken $accessToken) : RegistrationRequest
{
/** @var GoogleUser $resourceOwner */
$resourceOwner = $provider->getResourceOwner($accessToken);
$email = $resourceOwner->getEmail();
$providerAccountId = (string) $resourceOwner->getId();
return new RegistrationRequest('google', $providerAccountId, $email, $resourceOwner);
}
示例3: handle
/**
* @param Request $request
* @return \Psr\Http\Message\ResponseInterface|RedirectResponse
*/
public function handle(Request $request)
{
$redirectUri = (string) $request->getAttribute('originalUri', $request->getUri())->withQuery('');
$this->provider = $this->getProvider($redirectUri);
$session = $request->getAttribute('session');
$queryParams = $request->getQueryParams();
$code = array_get($queryParams, 'code');
$state = array_get($queryParams, 'state');
if (!$code) {
$authUrl = $this->provider->getAuthorizationUrl($this->getAuthorizationUrlOptions());
$session->set('oauth2state', $this->provider->getState());
return new RedirectResponse($authUrl . '&display=popup');
} elseif (!$state || $state !== $session->get('oauth2state')) {
$session->forget('oauth2state');
echo 'Invalid state. Please close the window and try again.';
exit;
}
$this->token = $this->provider->getAccessToken('authorization_code', compact('code'));
$owner = $this->provider->getResourceOwner($this->token);
$identification = $this->getIdentification($owner);
$suggestions = $this->getSuggestions($owner);
return $this->authResponse->make($request, $identification, $suggestions);
}
示例4: afterGetAccessToken
/**
* @param AbstractProvider $provider
* @param AccessToken $token
* @param string $providerName
* @param SS_HTTPRequest $request
*/
public function afterGetAccessToken(AbstractProvider $provider, AccessToken $token, $providerName, SS_HTTPRequest $request)
{
$user = $provider->getResourceOwner($token);
try {
$member = $this->memberFromResourceOwner($user, $providerName);
$this->owner->setMember($member);
} catch (TokenlessUserExistsException $e) {
return Security::permissionFailure($this->owner, $e->getMessage());
}
$result = $member->canLogIn();
if (!$result->valid()) {
return Security::permissionFailure($this->owner, $result->message());
}
$member->logIn();
}
示例5: fetchUserFromToken
/**
* Returns the "User" information (called a resource owner).
*
* @param AccessToken $accessToken
* @return \League\OAuth2\Client\Provider\ResourceOwnerInterface
*/
public function fetchUserFromToken(AccessToken $accessToken)
{
return $this->provider->getResourceOwner($accessToken);
}
示例6: getResourceOwner
/**
* Requests and returns the resource owner of given access token.
*
* @param AccessToken $token
* @return ResourceOwnerInterface
*/
public function getResourceOwner(AccessToken $token)
{
$this->openId = $this->getOpenId($token);
return parent::getResourceOwner($token);
}