예제 #1
0
 public function backoffice(array $data)
 {
     $this->validateParams($data, ['account_id']);
     try {
         $jwt = JWT::encode(['service_id' => $this->config->service_id, 'account_id' => $data['account_id'], 'nonce' => Nonce::generate(), 'timestamp' => time()], $this->config->backoffice_key, 'RS256');
         unset($data['account_id']);
         //defaults
         $data = array_merge(['code' => $jwt, 'scope' => $this->config->default_scopes], $data);
         return $this->getTokens($data, 'backoffice_code');
     } catch (\DomainException $e) {
         throw new TokenSignatureException('Backoffice JWT token could not be signed', 0, $e);
     }
 }
예제 #2
0
 public function backofficeClient(array $customPayload = [])
 {
     $key = $this->config->backoffice_key;
     $jwt = JWT::encode(array_merge(['service_id' => $this->config->service_id, 'nonce' => Nonce::generate(), 'timestamp' => time()], $customPayload), $key, 'RS256');
     return new ApiClient(['host' => $this->config->host, 'base_uri' => '/api/backoffice/', 'user_agent' => $this->config->user_agent, 'client_id' => $this->config->client_id, 'headers' => ['Authorization' => '7Pass-Backoffice ' . $jwt]]);
 }