Search code examples
google-cloud-platformgoogle-api-python-clientgoogle-text-to-speech

Why am I getting "invalid_grant: Invalid JWT Signature" with Google's Python TTS example?


I've followed the instructions for using Google's Python client for text-to-speech. The example freezes at the actual request line. Hitting control-C produces a trace ending with "invalid_grant: Invalid JWT Signature". I've verified that my key is active, the time on my machine is correct (for my location), and that "gcloud auth login" works properly. I've tried making a new key but encounter the same issue. How do I troubleshoot this problem?


Solution

  • For context, I'm using Windows 10 and Python 3.7.9. I deleted the key and created a new one exactly as John Hanley suggested. But, the problem continued when I ran my code in both my IDE (Visual Studio Code) and a separate Windows Command Prompt, which I was also using to set GOOGLE_APPLICATION_CREDENTIALS. I decided to check the environment variable directly in Windows Settings with admin privileges. I saw that GOOGLE_APPLICATION_CREDENTIALS was still set to an old JSON credentials file -- it had not changed. My only explanation is that I must not have opened the command prompt with admin privileges. I then set the environment variable to the new JSON file directly in Windows Settings. Google's Python client example for text-to-speech then ran correctly.