-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add google.auth.oauth2client - helpers for oauth2client migration #70
Conversation
@@ -0,0 +1,133 @@ | |||
# Copyright 2015 Google Inc. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
import oauth2client.service_account | ||
_HAS_OAUTH2CLIENT = True | ||
except ImportError: # pragma: NO COVER | ||
_HAS_OAUTH2CLIENT = False |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
|
||
def _convert_oauth2_credentials(credentials): | ||
"""Converts to :class:`google.oauth2.credentials.Credentials`.""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
|
||
def _convert_service_account_credentials(credentials): | ||
"""Converts to :class:`google.oauth2.service_account.Credentials`.""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
def _convert_service_account_credentials(credentials): | ||
"""Converts to :class:`google.oauth2.service_account.Credentials`.""" | ||
info = credentials.serialization_data | ||
info['token_uri'] = credentials.token_uri |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google.auth.credentials.Credentials: The converted credentials. | ||
|
||
Raises: | ||
EnvironmentError: If oauth2client is not installed. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if not _HAS_OAUTH2CLIENT: | ||
raise EnvironmentError( | ||
'oauth2client is not installed and is required in order to convert' | ||
'credentials.') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
return _CLASS_CONVERSION_MAP[credentials_class](credentials) | ||
except KeyError: | ||
raise ValueError( | ||
'Unable to convert {} to a google-auth credentials class.'.format( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -56,7 +56,7 @@ | |||
}, | |||
'BASIC': { | |||
'method-rgx': '[a-z_][a-z0-9_]{2,40}$', | |||
'function-rgx': '[a-z_][a-z0-9_]{2,40}$', | |||
'function-rgx': '[a-z_][a-z0-9_]{2,45}$', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
|
||
def test_import_has_app_engine(mock_oauth2client_gae_imports): | ||
reload_module(_oauth2client) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
The very first thing I thought when I saw the first file ( My reflex says make it non-public.
|
If I make it non-public, how would I expose the 'convert' function? On Tue, Nov 1, 2016, 8:04 PM Danny Hermes [email protected] wrote:
|
Just force the non-public module to show up in the Sphinx generated docs and then put a big warning in the module docstring that the module is intentionally non-public and not intended for typical users / new users. Then let them |
@dhermes I'm rather just leave it out of the docs in that case. Cool with you? |
@jonparrott I suppose it's cool with me, though you should still have very good and useful docstrings (especially the module docstring). |
Anything you'd add to the module docstring? |
Essentially
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhermes I've made it private and addressed all comments.
@@ -0,0 +1,133 @@ | |||
# Copyright 2015 Google Inc. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
import oauth2client.service_account | ||
_HAS_OAUTH2CLIENT = True | ||
except ImportError: # pragma: NO COVER | ||
_HAS_OAUTH2CLIENT = False |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
|
||
def _convert_oauth2_credentials(credentials): | ||
"""Converts to :class:`google.oauth2.credentials.Credentials`.""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
|
||
def _convert_service_account_credentials(credentials): | ||
"""Converts to :class:`google.oauth2.service_account.Credentials`.""" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
def _convert_service_account_credentials(credentials): | ||
"""Converts to :class:`google.oauth2.service_account.Credentials`.""" | ||
info = credentials.serialization_data | ||
info['token_uri'] = credentials.token_uri |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google.auth.credentials.Credentials: The converted credentials. | ||
|
||
Raises: | ||
EnvironmentError: If oauth2client is not installed. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if not _HAS_OAUTH2CLIENT: | ||
raise EnvironmentError( | ||
'oauth2client is not installed and is required in order to convert' | ||
'credentials.') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
return _CLASS_CONVERSION_MAP[credentials_class](credentials) | ||
except KeyError: | ||
raise ValueError( | ||
'Unable to convert {} to a google-auth credentials class.'.format( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -56,7 +56,7 @@ | |||
}, | |||
'BASIC': { | |||
'method-rgx': '[a-z_][a-z0-9_]{2,40}$', | |||
'function-rgx': '[a-z_][a-z0-9_]{2,40}$', | |||
'function-rgx': '[a-z_][a-z0-9_]{2,45}$', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
|
||
def test_import_has_app_engine(mock_oauth2client_gae_imports): | ||
reload_module(_oauth2client) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@dhermes you've approved, but I changed a lot since, care to take another look? ("No" is also acceptable as this is a completely private module) |
7f3a240
to
e3abc8a
Compare
Resolves #38
@dhermes please let me know what you think about exposing this as
google.auth.oauth2client
, and feel free to suggest a better name (oauth2client_compat
?)