google / aiyprojects-raspbian

API libraries, samples, and system images for AIY Projects (Voice Kit and Vision Kit)
https://aiyprojects.withgoogle.com/
Apache License 2.0
1.61k stars 692 forks source link

[Voice] Raspberry - Python - Google Voice kit - error 'invalid_client: Unauthorized' #737

Open indi-astro opened 3 years ago

indi-astro commented 3 years ago

Hello

I created a project 2 years ago with a voice kit that worked very well at the time.

It has not worked for a little over a year and now cannot be restarted! I have an error like: 'invalid_client: Unauthorized'

I tried to recreate my credentials, I even tried to create a new Google account but same result!

Have you ever encountered this scenario? A big thank you in advance to those who can help me!

Here's a snippet of the code:

def main():
    GPIO.setwarnings(False)
    status_ui = aiy.voicehat.get_status_ui()
    status_ui.status('starting')
    aiy.i18n.set_language_code('fr-FR')
**line 49 :    assistant = aiy.assistant.grpc.get_assistant()**

if __name__ == '__main__':
**line 90    main()**

and here is the log obtained:

Traceback (most recent call last):
  File "/home/pi/GoogleJarvis/Dev/test_google_voice_avec_bouton.py", line 90, in <module>
    main()
  File "/home/pi/GoogleJarvis/Dev/test_google_voice_avec_bouton.py", line 49, in main
    assistant = aiy.assistant.grpc.get_assistant()
  File "/opt/aiy/projects-python/src/aiy/assistant/grpc.py", line 80, in get_assistant
    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
  File "/opt/aiy/projects-python/src/aiy/assistant/auth_helpers.py", line 132, in get_assistant_credentials
    return _try_to_get_credentials(credentials_file)
  File "/opt/aiy/projects-python/src/aiy/assistant/auth_helpers.py", line 100, in _try_to_get_credentials
    return _load_credentials(_ASSISTANT_CREDENTIALS)
  File "/opt/aiy/projects-python/src/aiy/assistant/auth_helpers.py", line 63, in _load_credentials
    credentials.refresh(http_request)
  File "/home/pi/.local/lib/python3.5/site-packages/google/oauth2/credentials.py", line 136, in refresh
    self._client_secret))
  File "/home/pi/.local/lib/python3.5/site-packages/google/oauth2/_client.py", line 237, in refresh_grant
    response_data = _token_endpoint_request(request, token_uri, body)
  File "/home/pi/.local/lib/python3.5/site-packages/google/oauth2/_client.py", line 111, in _token_endpoint_request
    _handle_error_response(response_body)
  File "/home/pi/.local/lib/python3.5/site-packages/google/oauth2/_client.py", line 61, in _handle_error_response
    error_details, response_body)
google.auth.exceptions.RefreshError: ('invalid_client: Unauthorized', '{\n  "error": "invalid_client",\n  "error_description": "Unauthorized"\n}')
manoj7410 commented 3 years ago

@indi-astro Did you try to reflash the kit with https://github.com/google/aiyprojects-raspbian/releases/tag/v20210402 ?