'Google API reason: "ACCESS_TOKEN_EXPIRED" Error

I am using google vision api. The key given to has been returning the same error over and over again [reason: "ACCESS_TOKEN_EXPIRED"]. I had my friend use the same key and run the same code and his pc was able to run it but my pc still can't. I have remade the project, remade the service account, tried many many keys, uninstalled and reinstalled python, made enviornments. However, none of these were able to fix my problem. PLEASE HELP

enter image description here



Solution 1:[1]

ACCESS_TOKEN_EXPIRED means that the access token you have used has expired. You need a valid access token in order to access the api.

Access tokens are only valid for an hour and then they are expired. The solution is to either use your refresh token to request a new access token. Or to request access of the user again which will also result in a new access token.

Why your access token has expired could be that it has simply gone past the one hour mark. However there can be a rare instance where the server the machine is running on is not in sync with NTP causing the access token to appear to be expired even though it appeared to have been created under an hour ago. This is because without syncing with NTP server the time on the machine could be off by just enough to cause the token to appear to be expired.

This issue normally happens during the token exchange as the authorization code is shorter lived so its easer to spot NTP issues.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1