Skip to content

Commit 2f57f92

Browse files
committed
fix: handle error on service not enabled - closes #1116
1 parent 334b6e6 commit 2f57f92

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

googleapiclient/http.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ def _should_retry_response(resp_status, content):
116116
try:
117117
data = json.loads(content.decode("utf-8"))
118118
if isinstance(data, dict):
119-
reason = data["error"]["errors"][0]["reason"]
119+
reason = data["error"].get("status")
120+
if reason is None:
121+
reason = data["error"]["errors"][0]["reason"]
120122
else:
121123
reason = data[0]["error"]["errors"]["reason"]
122124
except (UnicodeDecodeError, ValueError, KeyError):

0 commit comments

Comments
 (0)