scopes; $this->scopes = array_filter($this->scopes, function(ScopeEntityInterface $scope): bool { return $scope->getIdentifier() !== PublicScopeRepository::OFFLINE_ACCESS; }); $token = Yii::$app->tokensFactory->createForOAuthClient($this); $this->scopes = $scopes; return (string)$token; } public function setPrivateKey(CryptKeyInterface $privateKey): void { // We use a general-purpose component to build JWT tokens, so there is no need to keep the key } public function getExpiryDateTime(): DateTimeImmutable { $expiryTime = $this->parentGetExpiryDateTime(); if ($this->hasScope(PublicScopeRepository::CHANGE_SKIN) || $this->hasScope(Permissions::OBTAIN_ACCOUNT_EMAIL)) { $expiryTime = min($expiryTime, CarbonImmutable::now()->addHour()); } return $expiryTime; } private function hasScope(string $scopeIdentifier): bool { foreach ($this->getScopes() as $scope) { if ($scope->getIdentifier() === $scopeIdentifier) { return true; } } return false; } }