Skip to content

Commit 3aba1d7

Browse files
committed
Cover auth request error case when requests request fails in HTTPX auth flow
1 parent c4b0673 commit 3aba1d7

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

firebase_admin/_http_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ class call this method to send HTTP requests out. Refer to
335335
336336
Raises:
337337
HTTPError: Any HTTPX exceptions encountered while making the HTTP call.
338+
RequestException: Any requests exceptions encountered while making the HTTP call.
338339
"""
339340
if 'timeout' not in kwargs:
340341
kwargs['timeout'] = self.timeout

firebase_admin/messaging.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,13 +533,11 @@ async def send_data(data):
533533
url=self._fcm_url,
534534
headers=self._fcm_headers,
535535
json=data)
536-
# HTTP/2 check
537-
if resp.http_version != 'HTTP/2':
538-
raise Exception('This messages was not sent with HTTP/2')
539-
resp.raise_for_status()
540-
# except httpx.HTTPStatusError as exception:
541536
except httpx.HTTPError as exception:
542537
return SendResponse(resp=None, exception=self._handle_fcm_httpx_error(exception))
538+
# Catch errors caused by the requests library during authorization
539+
except requests.exceptions.RequestException as exception:
540+
return SendResponse(resp=None, exception=self._handle_fcm_error(exception))
543541
else:
544542
return SendResponse(resp.json(), exception=None)
545543

0 commit comments

Comments
 (0)