hi there!
|
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 |
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 of oauth2clientlibrary settings (about timeouts). if you don't ask doing another (and yes: you DON'T ask -- in this example).
-
oauth2client library uses defaults of httplib2 library settings (about timeouts). if you don't ask doing another.
-
httplib2 library 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.
hi there!
quickstart-python/messaging/messaging.py
Lines 25 to 33 in 688fcfa
problem is here
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()tocredentials.get_access_token(http=my_http_factory_with_timeouts_blahblahblah)(and definedef my_http_factory_with_timeouts_blahblahblah()somewhere)or
fix the library
oauth2clientitself.