you write nothing about timeouts when do authorization
hi there!
https://github.com/firebase/quickstart-python/blob/688fcfa8068dcac67978a171df828c9e77cd320e/messaging/messaging.py#L25-L33
problem is here
# [START retrieve_access_token]
def _get_access_token():
"""Retrieve a valid access token that can be used to authorize requests.
:return: Access token.
"""
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'service-account.json', SCOPES)
access_token_info = credentials.get_access_token()
return access_token_info.access_token
# [END retrieve_access_token]
authorization formally is incorrect, it could be freezen (for infinite time) in rary moments. see the full chain of the problem:
-
get_access_token()uses defaults ofoauth2clientlibrary settings (about timeouts). if you don't ask doing another (and yes: you DON'T ask -- in this example). -
oauth2clientlibrary uses defaults ofhttplib2library settings (about timeouts). if you don't ask doing another. -
httplib2library uses defaults of python sockets (std lib) settings (about timeouts). if you don't ask doing another. -
python sockets (std lib) uses defaults of linux settings. if you don't ask doing another.
-
defaults of linux timeout settings means ability freezing of programme for infinite time when doing
read().
how to fix it?
change invoking credentials.get_access_token() to credentials.get_access_token(http=my_http_factory_with_timeouts_blahblahblah) (and define def my_http_factory_with_timeouts_blahblahblah() somewhere)
or
fix the library oauth2client itself.