Skip to content

Commit cf0fcc0

Browse files
authored
remove misleading raise_for_status (GoogleCloudPlatform#2948)
When the response has error, the error detail is not exposed because of raise_for_status, so remove it and show the detailed message. For instance, the detailed error is UNAUTHENTICATED:Method doesn't allow unregistered callers (callers without established identity). Please use API Key or other form of API consumer identity to call this API. but we only got requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url.
1 parent 00d8071 commit cf0fcc0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

endpoints/getting-started/clients/google-jwt-client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def make_jwt_request(signed_jwt, url='https://your-endpoint.com'):
6868
'content-type': 'application/json'
6969
}
7070
response = requests.get(url, headers=headers)
71-
71+
print(response.status_code, response.content)
7272
response.raise_for_status()
73-
return response.text
73+
7474
# [END endpoints_jwt_request]
7575

7676

@@ -96,4 +96,4 @@ def make_jwt_request(signed_jwt, url='https://your-endpoint.com'):
9696
args.sa_email,
9797
args.audience,
9898
expiry_length)
99-
print(make_jwt_request(keyfile_jwt, args.host))
99+
make_jwt_request(keyfile_jwt, args.host)

0 commit comments

Comments
 (0)