Skip to content

you write nothing about timeouts when do authorization #16

@antonov-impulsm

Description

@antonov-impulsm

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:

  1. 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).

  2. oauth2client library uses defaults of httplib2 library settings (about timeouts). if you don't ask doing another.

  3. httplib2 library uses defaults of python sockets (std lib) settings (about timeouts). if you don't ask doing another.

  4. python sockets (std lib) uses defaults of linux settings. if you don't ask doing another.

  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions