Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

invalid_grant failures under Python3 #125

Closed
tseaver opened this issue Feb 3, 2015 · 4 comments · Fixed by #126 or googleapis/google-cloud-python#676
Closed

invalid_grant failures under Python3 #125

tseaver opened this issue Feb 3, 2015 · 4 comments · Fixed by #126 or googleapis/google-cloud-python#676

Comments

@tseaver
Copy link

tseaver commented Feb 3, 2015

When running with the branch from googleapis/google-cloud-python#580:

$ .tox/regression3/bin/python regression/run_regression.py --package=storage
ERROR

======================================================================
ERROR: setUpModule (storage)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tseaver/projects/agendaless/Google/src/gcloud-python/regression/storage.py", line 42, in setUpModule
    SHARED_BUCKETS['test_bucket'] = CONNECTION.create_bucket(bucket_name)
  File "/home/tseaver/projects/agendaless/Google/src/gcloud-python/.tox/regression3/lib/python3.4/site-packages/gcloud/storage/connection.py", line 351, in create_bucket
    data={'name': bucket.name})
  File "/home/tseaver/projects/agendaless/Google/src/gcloud-python/.tox/regression3/lib/python3.4/site-packages/gcloud/storage/connection.py", line 239, in api_request
    method=method, url=url, data=data, content_type=content_type)
  File "/home/tseaver/projects/agendaless/Google/src/gcloud-python/.tox/regression3/lib/python3.4/site-packages/gcloud/storage/connection.py", line 176, in make_request
    body=data)
  File "/home/tseaver/projects/agendaless/Google/src/gcloud-python/.tox/regression3/lib/python3.4/site-packages/oauth2client/util.py", line 135, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/tseaver/projects/agendaless/Google/src/gcloud-python/.tox/regression3/lib/python3.4/site-packages/oauth2client/client.py", line 530, in new_request
    self._refresh(request_orig)
  File "/home/tseaver/projects/agendaless/Google/src/gcloud-python/.tox/regression3/lib/python3.4/site-packages/oauth2client/client.py", line 744, in _refresh
    self._do_refresh_request(http_request)
  File "/home/tseaver/projects/agendaless/Google/src/gcloud-python/.tox/regression3/lib/python3.4/site-packages/oauth2client/client.py", line 807, in _do_refresh_request
    raise AccessTokenRefreshError(error_msg)
oauth2client.client.AccessTokenRefreshError: invalid_grant

----------------------------------------------------------------------
  • Those tests use the GOOGLE_APPLICATION_CREDENTIALS envvar, and run fine under Python2.
  • All gcloud-python unit tests pass on that branch under Python2 and Python3.
@craigcitro
Copy link
Contributor

cc @anthmgoogle

@dhermes
Copy link
Contributor

dhermes commented Feb 4, 2015

It's a formatting issue of bytes vs. string.

In Python2:

>>> body
'assertion=eyJ...'

In Python3:

>>> body
'assertion=b%22b%27eyJ...'

Decoding, this is a bit of a mess:

>>> urllib.unquote('b%22b%27eyJ...')
'b"b\'eyJ...'

Python2

>>> urlparse.parse_qs(WORKS)
{'assertion': ['eyJ...REDACTED...Q.eyJ...REDACTED...X0.3L2...REDACTED...Adg'],
 'grant_type': ['urn:ietf:params:oauth:grant-type:jwt-bearer']}

Python3

>>> urlparse.parse_qs(NOT_WORKS)
{'assertion': ['b"b\'eyJ...REDACTED...fQ\'.b\'eyJ...REDACTED...In0\'".v4M...REDACTED...g0'],
 'grant_type': ['urn:ietf:params:oauth:grant-type:jwt-bearer']}

@dhermes
Copy link
Contributor

dhermes commented Feb 4, 2015

@craigcitro Can you assign this issue to me? I am working on it.

@craigcitro
Copy link
Contributor

@dhermes it won't let me assign to anyone outside our org, unfortunately.

dhermes added a commit to dhermes/oauth2client that referenced this issue Feb 4, 2015
Fixes googleapis#125.

NOTE: '%s.%s' does not behave the same between versions and should
      be removed throughout this library.

I will be following this up with a set of regression tests (hopefully
some of which will fail) and we can assess the damage of other uses
of '%s'.
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Mar 24, 2015
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Mar 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants