Try to fix API: adjust to new urls, but still receiving error code 400

This commit is contained in:
Julie Lenaerts 2024-05-07 11:15:10 +02:00
parent 684f28291a
commit d82d534a4c
4 changed files with 10 additions and 9 deletions

View File

@ -35,7 +35,9 @@ class ApiWrapper
public function __construct(private $clientId, private $clientSecret, private readonly ChillRedis $redis)
{
$this->client = new Client([
'base_uri' => 'https://entreprise.pole-emploi.fr/connexion/oauth2/access_token',
// 'base_uri' => 'https://entreprise.pole-emploi.fr/connexion/oauth2/access_token',
'base_uri' => 'https://francetravail.io/connexion/oauth2/access_token',
]);
}
@ -49,20 +51,19 @@ class ApiWrapper
return $data->access_token;
}
try {
$response = $this->client->post('', [
'query' => ['realm' => '/partenaire'],
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
],
// 'body' => 'grant_type=client_credentials&client_id=PAR_chillcsconnectesdev_0e20082886f1bc5d8ff4f8b34868603e2bcc7ed6bc5963e648e3709c639aced9&client_secret=4e626fa3123bcf4d299591c09731fa3242a7e75bbc003955f903aebc33cdd022&scope=api_romev1%20nomenclatureRome%20application_PAR_chillcsconnectesdev_0e20082886f1bc5d8ff4f8b34868603e2bcc7ed6bc5963e648e3709c639aced9'
'form_params' => [
'grant_type' => 'client_credentials',
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'scope' => \implode(' ', \array_merge($scopes, ['application_'.$this->clientId])),
],
// ]);
]);
} catch (ClientException $e) {
dump($e->getResponse());

View File

@ -44,14 +44,14 @@ class PartenaireRomeAppellation
$this->wrapper = $wrapper;
$this->logger = $logger;
$this->client = new Client([
'base_uri' => 'https://api.emploi-store.fr/partenaire/rome/v1/',
'base_uri' => 'https://api.francetravail.io/partenaire/rome-metiers',
]);
}
private function getBearer()
{
return $this->wrapper->getPublicBearer([
'api_romev1',
'api_rome-metiersv1',
'nomenclatureRome',
]);
}
@ -67,7 +67,7 @@ class PartenaireRomeAppellation
$parameters = [
'query' => [
'q' => $search,
'qf' => 'libelle',
'fq' => 'libelle',
],
'headers' => [
'Authorization' => 'Bearer '.$bearer,

View File

@ -9,6 +9,6 @@ services:
$logger: '@Psr\Log\LoggerInterface'
Chill\FranceTravailApiBundle\Controller\RomeController:
arguments:
$apiAppellation: '@Chill\FranceTravailApiBundle\ApiHelper\PartenaireRomeAppellation'
autowire: true
autoconfigure: true
tags: ['controller.service_arguments']

View File

@ -107,7 +107,7 @@ class PickRomeAppellationType extends AbstractType
$view->vars['attr']['data-rome-appellation-picker'] = true;
$view->vars['attr']['data-select-interactive-loading'] = true;
$view->vars['attr']['data-search-url'] = $this->urlGenerator
->generate('chill_pole_emploi_api_appellation_search', ['_format' => 'json']);
->generate('chill_france_travail_api_appellation_search', ['_format' => 'json']);
$view->vars['attr']['data-placeholder'] = 'Choisir une appellation';
$view->vars['attr']['data-no-results-label'] = $this->translator->trans('select2.no_results');
$view->vars['attr']['data-error-load-label'] = $this->translator->trans('select2.error_loading');