'OAuth2 expired always after a couple of hours

I am trying to build some code to do some processing in youtube channel, it required that I generate OAuth2 client id and secret and I created them and it works but after a couple of hours I start getting this error

A service error occurred: { "error": { "code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "errors": [ { "message": "Invalid Credentials", "domain": "global", "reason": "authError", "location": "Authorization", "locationType": "header" } ], "status": "UNAUTHENTICATED" } }

I solved it by removing the app from third-party connected apps and signing out from the account and logging in again, then I get the Authorize app steps and its return to work again, but it happen again

I do not know why the credentials expire and if there is any way to make them always valid and solve this problem permanently



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source