tokens->verifyAccessToken($token); } catch (TokenExpiredException $e) { throw new UnauthorizedHttpException('Token expired', previous: $e); } catch (TokenRevokedException $e) { throw new UnauthorizedHttpException('Token has been revoked', previous: $e); } catch (InvalidTokenException $e) { throw new UnauthorizedHttpException('Incorrect token', previous: $e); } return new self($parsedToken); } public function getToken(): UnencryptedToken { return $this->token; } public function getAccount(): ?Account { return Account::findOne(['id' => $this->getReader()->getAccountId()]); } public function getAssignedPermissions(): array { return $this->getReader()->getScopes() ?? []; } public function getId(): string { return $this->token->toString(); } /** @codeCoverageIgnoreStart */ public function getAuthKey() { throw new NotSupportedException('This method used for cookie auth, except we using Bearer auth'); } public function validateAuthKey($authKey) { throw new NotSupportedException('This method used for cookie auth, except we using Bearer auth'); } /** * @throws NotSupportedException */ public static function findIdentity($id) { throw new NotSupportedException('This method used for cookie auth, except we using Bearer auth'); } /** @codeCoverageIgnoreEnd */ private function getReader(): TokenReader { if ($this->reader === null) { $this->reader = new TokenReader($this->token); } return $this->reader; } }