public function TokenAuthUser::__construct in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 8 src/Authentication/TokenAuthUser.php \Drupal\simple_oauth\Authentication\TokenAuthUser::__construct()
- 8.2 src/Authentication/TokenAuthUser.php \Drupal\simple_oauth\Authentication\TokenAuthUser::__construct()
- 8.3 src/Authentication/TokenAuthUser.php \Drupal\simple_oauth\Authentication\TokenAuthUser::__construct()
- 5.x src/Authentication/TokenAuthUser.php \Drupal\simple_oauth\Authentication\TokenAuthUser::__construct()
Constructs a TokenAuthUser object.
Parameters
\Drupal\simple_oauth\Entity\Oauth2TokenInterface $token: The underlying token.
Throws
\League\OAuth2\Server\Exception\OAuthServerException When there is no user.
File
- src/
Authentication/ TokenAuthUser.php, line 50
Class
- TokenAuthUser
- The decorated user class with token information.
Namespace
Drupal\simple_oauth\AuthenticationCode
public function __construct(Oauth2TokenInterface $token) {
$this->consumer = $token
->get('client')->entity;
if (!($this->subject = $token
->get('auth_user_id')->entity)) {
$this->subject = $this->consumer
->get('user_id')->entity;
}
if (!$this->subject) {
throw OAuthServerException::invalidClient();
}
$this->token = $token;
}