Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Add explanation for when error 403 happens #373

Open
wants to merge 1 commit into
base: aiyprojects
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/aiy/assistant/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import aiy.assistant.device_helpers
import aiy.audio
import aiy.voicehat
from requests.exceptions import HTTPError

# Global variables. They are lazily initialized.
_assistant_recognizer = None
Expand Down Expand Up @@ -78,5 +79,10 @@ def get_assistant():
global _assistant_recognizer
if not _assistant_recognizer:
credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
_assistant_recognizer = _AssistantRecognizer(credentials)
try:
_assistant_recognizer = _AssistantRecognizer(credentials)
except HTTPError as e:
if e.status_code == 403:
print('Got HTTP error 403, did you remember to enable the Google Assistant API?')
raise
return _assistant_recognizer