synolia/SyliusAkeneoPlugin

[Bug] Refresh token expire

oallain opened this issue · 1 comments

Describe the bug
The connection to Akeneo may be interrupted during an import and the refresh token may no longer be valid, which produces a fatal error.

To Reproduce
I don't have a scenario to reproduce this issue, it's quite random.

Expected behavior
Catch error and auto login to akeneo.

Screenshots

17:25:37 NOTICE    [akeneo] akeneo:import:attributes
17:25:38 DEBUG     [akeneo] Synolia\SyliusAkeneoPlugin\Task\Attribute\RetrieveAttributesTask
17:25:38 NOTICE    [akeneo] Retrieve Attribute from Akeneo API

In HttpExceptionHandler.php line 58:
                                                                           
  [Akeneo\Pim\ApiClient\Exception\UnprocessableEntityHttpException (422)]  
  Refresh token is invalid or has expired                                  
                                                                           

Exception trace:
  at /app/vendor/akeneo/api-php-client/src/Client/HttpExceptionHandler.php:58
 Akeneo\Pim\ApiClient\Client\HttpExceptionHandler->transformResponseToException() at /app/vendor/akeneo/api-php-client/src/Client/HttpClient.php:47
 Akeneo\Pim\ApiClient\Client\HttpClient->sendRequest() at /app/vendor/akeneo/api-php-client/src/Api/AuthenticationApi.php:80
 Akeneo\Pim\ApiClient\Api\AuthenticationApi->authenticate() at /app/vendor/akeneo/api-php-client/src/Api/AuthenticationApi.php:59
 Akeneo\Pim\ApiClient\Api\AuthenticationApi->authenticateByRefreshToken() at /app/vendor/akeneo/api-php-client/src/Client/AuthenticatedHttpClient.php:68
 Akeneo\Pim\ApiClient\Client\AuthenticatedHttpClient->sendRequest() at /app/vendor/akeneo/api-php-client/src/Client/ResourceClient.php:54
 Akeneo\Pim\ApiClient\Client\ResourceClient->getResource() at /app/vendor/akeneo/api-php-client/src/Client/ResourceClient.php:85
 Akeneo\Pim\ApiClient\Client\ResourceClient->getResources() at /app/vendor/akeneo/api-php-client/src/Api/AttributeApi.php:61
 Akeneo\Pim\ApiClient\Api\AttributeApi->listPerPage() at /app/vendor/akeneo/api-php-client/src/Api/AttributeApi.php:71
 Akeneo\Pim\ApiClient\Api\AttributeApi->all() at /app/vendor/synolia/sylius-akeneo-plugin/src/Task/Attribute/RetrieveAttributesTask.php:36
 Synolia\SyliusAkeneoPlugin\Task\Attribute\RetrieveAttributesTask->__invoke() at /app/vendor/synolia/sylius-akeneo-plugin/src/Pipeline/Processor.php:31
 Synolia\SyliusAkeneoPlugin\Pipeline\Processor->process() at /app/vendor/league/pipeline/src/Pipeline.php:34
 League\Pipeline\Pipeline->process() at /app/vendor/synolia/sylius-akeneo-plugin/src/Command/ImportAttributesCommand.php:77
 Synolia\SyliusAkeneoPlugin\Command\ImportAttributesCommand->execute() at /app/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /app/vendor/symfony/console/Application.php:1023
 Symfony\Component\Console\Application->doRunCommand() at /app/vendor/symfony/framework-bundle/Console/Application.php:97
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /app/vendor/symfony/console/Application.php:271
 Symfony\Component\Console\Application->doRun() at /app/vendor/symfony/framework-bundle/Console/Application.php:83
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:147
 Symfony\Component\Console\Application->run() at /app/bin/console:38

Fixed by #40