8000 Handling HTTP errors from local metadata service (#212) · fossabot/firebase-admin-python@c97a510 · GitHub
[go: up one dir, main page]

Skip to content

Commit c97a510

Browse files
authored
Handling HTTP errors from local metadata service (firebase#212)
* Handling HTTP errors from local metadata service * Decoding the error response correctly
1 parent abd3980 commit c97a510

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

firebase_admin/_token_gen.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ def _init_signing_provider(self):
120120
# Attempt to discover a service account email from the local Metadata service. Use it
121121
# with the IAM service to sign bytes.
122122
resp = self.request(url=METADATA_SERVICE_URL, headers={'Metadata-Flavor': 'Google'})
123+
if resp.status != 200:
124+
raise ValueError(
125+
'Failed to contact the local metadata service: {0}.'.format(resp.data.decode()))
123126
service_account = resp.data.decode()
124127
return _SigningProvider.from_iam(self.request, google_cred, service_account)
125128

0 commit comments

Comments
 (0)
0