marcreichel / igdb-laravel

Simplify the integration of the IGDB API into your Laravel app. Including IGDB webhook support.
https://marcreichel.dev/docs/igdb-laravel
MIT License
107 stars 22 forks source link

401 Error with Token #57

Closed Rosw3lluk closed 2 years ago

Rosw3lluk commented 2 years ago

Hello, I seem to be experiencing an issue similar to closed issue #47

The token works perfectly fine for 24 hours, but after a nights sleep and i start my dev server up in the morning it seems to state that the token is invalid, so i'm not sure if its refreshing the token properly?

If i go ahead and type php artisan cache:forget igdb_cache.access_token

Everything works normally again? I'm running the latest version of Laravel and the latest version igdb-laravel ("marcreichel/igdb-laravel": "^3.5")

I'm fairly new to Laravel and the IGDB API so apologise if i have missed something, however everything has been working perfectly, my project also uses the direct helix twitch api with the same authentication tokens, and those calls still work perfectly on the website so i know the tokens are working correctly and have not been revoked etc.., its just anything related to IGDB requests which use this wrapper.

If you need anything, logs etc.. please let me know, (and where to get them) and ill gladly provide them :)

Thank you.

marcreichel commented 2 years ago

@roswellgames May I ask what the dev server you're using is? Maybe a vagrant box which does not sync the server time properly after being woken up? So the cache thinks it is still valid, but actually it is not? It's just guessing though.

Some more information on how you develop your app and what your development environment is could be useful 👍🏼

Rosw3lluk commented 2 years ago

Hey ive closed this as i have resolved this issue by linking my twitch api modules, socialites and igdb using the same key, im not sure but possibly where another API Request was happening (a new token was being generated) potentially invalidated the igdb requested token? not sure but it seems to have resolved the issue.

adzay commented 2 years ago

I just had this issue (IGDB randomly giving 401 error) and resolved it using your suggestion above:

php artisan cache:forget igdb_cache.access_token

sneakingJ commented 2 years ago

I also had this problem. So it seems like the cache does not get deleted automatically after 24 hours? I could solve it by attaching the method ::cache(120) to my search call.

marcreichel commented 2 years ago

I've released v6.3.1 which reduces the access token (cache) lifetime by 60 seconds so when the access token is about to expire in 60 seconds a new token will be fetched already. And I've also added request retries so when a request fails it will be retried 3 times.

Full Changelog: https://github.com/marcreichel/igdb-laravel/compare/3.6.0...3.6.1

Let me know if this helps to resolve your problems.

sneakingJ commented 2 years ago

@marcreichel I updated your package, removed the ::cache method again and waited for 24 hours. Seems to work :) Thanks.