本文整理汇总了PHP中Symfony\Component\Security\Core\Authentication\Token\TokenInterface::getApiUser方法的典型用法代码示例。如果您正苦于以下问题:PHP TokenInterface::getApiUser方法的具体用法?PHP TokenInterface::getApiUser怎么用?PHP TokenInterface::getApiUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Core\Authentication\Token\TokenInterface
的用法示例。
在下文中一共展示了TokenInterface::getApiUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
public function authenticate(TokenInterface $token)
{
try {
$localUser = $this->userProvider->loadUserByUsername($token->getUser());
$authorizedToken = new ConnectToken($localUser, $token->getAccessToken(), $token->getApiUser(), $this->providerKey, $token->getScope(), $localUser->getRoles());
$authorizedToken->setAttributes($token->getAttributes());
return $authorizedToken;
} catch (\Exception $repositoryProblem) {
throw new AuthenticationServiceException($repositoryProblem->getMessage(), $token, 0, $repositoryProblem);
}
}
示例2: authenticate
public function authenticate(TokenInterface $token)
{
try {
$localUser = $this->userProvider->loadUserByUsername($token->getUser());
$authorizedToken = new ConnectToken($localUser, $token->getAccessToken(), $token->getApiUser(), $this->providerKey, $token->getScope(), $localUser->getRoles());
$authorizedToken->setAttributes($token->getAttributes());
return $authorizedToken;
} catch (\Exception $repositoryProblem) {
if (!method_exists('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationServiceException', 'setToken')) {
throw new AuthenticationServiceException($repositoryProblem->getMessage(), $token, 0, $repositoryProblem);
} else {
$e = new AuthenticationServiceException($repositoryProblem->getMessage(), 0, $repositoryProblem);
$e->setToken($token);
throw $e;
}
}
}