Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Fixing JSON key service account assertions in Python3. #126

Merged
merged 1 commit into from
Feb 6, 2015

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Feb 4, 2015

Fixes #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'.

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
Copy link
Contributor Author

dhermes commented Feb 4, 2015

To verify:

from __future__ import print_function

from oauth2client import client
import httplib2


SEPARATOR = '=' * 60
SCOPES = ('https://www.googleapis.com/auth/userinfo.email',)
CREDENTIALS_FILENAME = '/path/to/credentials.json'

CREDENTIALS = client._get_application_default_credential_from_file(
    CREDENTIALS_FILENAME).create_scoped(SCOPES)


print('oauth2client.client.__file__ (make sure this is local):')
print(repr(client.__file__))
print(SEPARATOR)

print('CREDENTIALS.refresh_token before:')
print(repr(CREDENTIALS.refresh_token))
print('CREDENTIALS.access_token before:')
print(repr(CREDENTIALS.access_token))
print(SEPARATOR)

HTTP = httplib2.Http()
result = CREDENTIALS.refresh(HTTP)

print('refresh result:')
print(repr(result))
print(SEPARATOR)

print('CREDENTIALS.refresh_token after:')
print(repr(CREDENTIALS.refresh_token))
print('CREDENTIALS.access_token after:')
print(repr(CREDENTIALS.access_token))

@dhermes
Copy link
Contributor Author

dhermes commented Feb 4, 2015

For me this results in outputs

Python 2

oauth2client.client.__file__ (make sure this is local):
'/home/dhermes/oauth2client/oauth2client/client.pyc'
============================================================
CREDENTIALS.refresh_token before:
None
CREDENTIALS.access_token before:
None
============================================================
refresh result:
None
============================================================
CREDENTIALS.refresh_token after:
None
CREDENTIALS.access_token after:
u'ya29.EAG...'

Python 3

oauth2client.client.__file__ (make sure this is local):
'/home/dhermes/oauth2client/oauth2client/client.py'
============================================================
CREDENTIALS.refresh_token before:
None
CREDENTIALS.access_token before:
None
============================================================
refresh result:
None
============================================================
CREDENTIALS.refresh_token after:
None
CREDENTIALS.access_token after:
'ya29.EAH...'

@dhermes
Copy link
Contributor Author

dhermes commented Feb 4, 2015

@craigcitro PTAL

craigcitro added a commit that referenced this pull request Feb 6, 2015
Fixing JSON key service account assertions in Python3.
@craigcitro craigcitro merged commit cd6a9c4 into googleapis:master Feb 6, 2015
@dhermes
Copy link
Contributor Author

dhermes commented Feb 6, 2015

w00t.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

invalid_grant failures under Python3
3 participants