websmurf / laravel-exact-online

Laravel Exact Online wrapper around the PHP API
MIT License
11 stars 14 forks source link

Could not refresh tokens - Error 401 #4

Closed Dietermartens closed 3 years ago

Dietermartens commented 3 years ago

Hi,

When we try to use the library in just Laravel it works fine, but when we implement it in Queue's (async) after a couple of requests the library loses the refresh token.

Do you have any idea to fix this? The queue is configured to only run one task at a time to prevent tokens from being lost.

websmurf commented 3 years ago

Yeah, there's a long on-going discussion in this regard here https://github.com/picqer/exact-php-client/issues/385 I've implemented a similar locking in #3, however there seems to be some improvements in that area on the Picqer package, so will have another look at it

(I'm running into the same issues)

websmurf commented 3 years ago

Have pushed a new v0.5.0-beta.1 release that applies the principle that's discussed here https://github.com/picqer/exact-php-client/issues/385 and https://github.com/picqer/exact-php-client/pull/449 to see if that helps

Dietermartens commented 3 years ago

Yeah i've read the discussions... thx for the update!

Meanwhile i've implemented the queue lock mechanism of Laravel 8. This makes sure there will only be one simultaneous job in the queue. https://laravel.com/docs/8.x/queues#unique-jobs

websmurf commented 3 years ago

Pushed out another release that implements the Atomic Lock option of Laravel in stead of a custom implementation as well to further improve.

websmurf commented 3 years ago

I haven't had the 401 error on my setup (with queueing as well) with the v0.5.0.beta2, so I've promoted that one to be the stable v0.5.0. Let me know if you run into anything with the latest stable.