on en a besoin parce que c'est du M2M. $tokenResponse = $this->getTokenResponse(); $accessToken = $tokenResponse->toArray()['access_token']; // data must match easy check database $projectJson = $this->getProjectToJson($project); // 2. Call the Client Application's Webhook/API $this->httpClient->request('POST', $clientAppUrl . '/api/v1/project/create', [ 'headers' => ['Authorization' => 'Bearer ' . $accessToken], 'json' => $projectJson ]); } public function editRemoteProject(string $clientAppUrl, Project $project): void { $tokenResponse = $this->getTokenResponse(); $accessToken = $tokenResponse->toArray()['access_token']; // data must match easy check database $projectJson = $this->getProjectToJson($project); // 2. Call the Client Application's Webhook/API $this->httpClient->request('PUT', $clientAppUrl . '/api/v1/project/edit/'. $project->getId(), [ 'headers' => ['Authorization' => 'Bearer ' . $accessToken], 'json' => $projectJson ]); } public function deleteRemoteProject(string $clientAppUrl, int $projectId): void { $tokenResponse = $this->getTokenResponse(); $accessToken = $tokenResponse->toArray()['access_token']; // 2. Call the Client Application's Webhook/API $this->httpClient->request('DELETE', $clientAppUrl . '/api/v1/project/delete/'. $projectId, [ 'headers' => ['Authorization' => 'Bearer ' . $accessToken], ]); } public function getTokenResponse(): ResponseInterface{ $portalClient = $this->entityManager->getRepository(Client::class)->findOneBy(['identifier' => $this->clientIdentifier]); return $this->httpClient->request('POST', $this->appUrl . 'token', [ 'auth_basic' => [$portalClient->getIdentifier(),$portalClient->getSecret()], // ID and Secret go here 'body' => [ 'grant_type' => 'client_credentials', ], ]); } public function getProjectToJson(Project $project): array { return [ 'id' => $project->getId(), 'projet' => $project->getName(), 'entity_id' => $project->getOrganization()->getId(), 'bdd' => $project->getBddName(), 'isactive' => $project->isActive(), 'logo' => $project->getLogo(), 'timestamp'=> $project->getTimestampPrecision(), 'deletion' => $project->isDeletionAllowed() ]; } }