* @license http://www.gnu.org/licenses/agpl-3.0 * @link http://fusio-project.org */ class Client { /** @var string */ private $baseUri; /** @var string */ private $appKey; /** @var string */ private $appSecret; /** @var string[]|null */ private $scopes; /** @var TokenStoreInterface */ private $tokenStore; /** @var HttpClient|null */ private $httpClient; /** @var SchemaManager|null */ private $schemaManager; /** * @param string $baseUri * @param string $appKey * @param string $appSecret * @param array|null $scopes * @param HttpClient|null $httpClient * @param SchemaManager|null $schemaManager */ public function __construct( string $baseUri, string $appKey, string $appSecret, ?array $scopes = null, ?TokenStoreInterface $tokenStore = null, ?HttpClient $httpClient = null, ?SchemaManager $schemaManager = null, ) { $this->baseUri = $baseUri; $this->appKey = $appKey; $this->appSecret = $appSecret; $this->scopes = $scopes; $this->tokenStore = $tokenStore ?? new MemoryTokenStore(); $this->httpClient = $httpClient; $this->schemaManager = $schemaManager; } public function authenticate(): AccessToken { $token = $this->tokenStore->get(); if ($token && $token->getExpiresIn() > time()) { return $token; } $authenticator = new Authenticator($this->baseUri, $this->httpClient); $token = $authenticator->requestAccessToken($this->appKey, $this->appSecret, $this->scopes); $this->tokenStore->persist($token); return $token; } public function backend(): Backend\Client { $token = $this->authenticate(); return new Backend\Client($this->baseUri, $token->getAccessToken(), $this->httpClient, $this->schemaManager); } public function consumer(): Consumer\Client { $token = $this->authenticate(); return new Consumer\Client($this->baseUri, $token->getAccessToken(), $this->httpClient, $this->schemaManager); } } __halt_compiler();----SIGNATURE:----QZjg3ZJHRTkCQJx5TxlD6Xc/R+n6tQzNvp+nM9r/LMRWzbunjJn1t8QDezThvNs3DU5fGQh4xKeaA47MK69NNYjJu3/KJVaFtkQhLB5eD+EbWHWhF2v7rveYPc3sPZ6Zy0EGDL/yz3CDtMwXuqrkMC2RUgzoDif3XcrcoEgjKakgliKmV8AoGByvFFtCYECgv/UsTH3icEKAmY1Zhuex2/LPNt1QtcA+TKonFFTKOVqKwyrkG/4DPMSKyrmfMFRbq9G76ewmiqltElRLA4UtGZgHAADGtejV/qk54MZ1/jz1lt7fC68GRBM5gsHAPFwakQ7mS13Xz6mptQjF3DAgeV3fNIX4I86yftLiGfUTflQfW5lsftKgFmW9GS/1xmwSfSyDnf2B4AhwSGSikCHrvSSpDnQ/4n8fCHT9VWYnlaHbeRcJH/7t2diPZKWayt5KPuU5vIGjqwwHPDxLKsFopwYJ1wKzv0KWds/RvACljmMXqoOUa5zBmqYtbMrHYACfMEx44iG4Osy3gkP5k4ThNEvnbnYdOenILnZ5xvX5RjhG/QS0aFUleK6g83Id6lxwyvUY+CeeKfQLYJD8ReZqrMdoEvRlZRM0BVNEAtoecT9iCmwET0wN6qtH3p42X3O6TIN6P4BKs8FBJY3GEP5Z/MtQTogKxz78RJcaZ19eMWc=----ATTACHMENT:----NTQ3MTI0Mzc2NDg2MTYzNyA5NDE1MDQ0MTk4MDgzODQ3IDQyNzYyNDcwMjYxNzc1MzY=