Add google.auth.oauth2client - helpers for oauth2client migration#70
Add google.auth.oauth2client - helpers for oauth2client migration#70
Conversation
google/auth/oauth2client.py
Outdated
| @@ -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.
google/auth/oauth2client.py
Outdated
| 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.
google/auth/oauth2client.py
Outdated
|
|
||
|
|
||
| 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.
google/auth/oauth2client.py
Outdated
|
|
||
|
|
||
| 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/oauth2client.py
Outdated
| 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.
google/auth/oauth2client.py
Outdated
| 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.
google/auth/oauth2client.py
Outdated
| 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.
scripts/run_pylint.py
Outdated
| '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 notifications@github.com 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
|
google/auth/oauth2client.py
Outdated
| @@ -0,0 +1,133 @@ | |||
| # Copyright 2015 Google Inc. | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/auth/oauth2client.py
Outdated
| 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.
google/auth/oauth2client.py
Outdated
|
|
||
|
|
||
| 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.
google/auth/oauth2client.py
Outdated
|
|
||
|
|
||
| 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/oauth2client.py
Outdated
| 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.
google/auth/oauth2client.py
Outdated
| 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.
google/auth/oauth2client.py
Outdated
| 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.
scripts/run_pylint.py
Outdated
| '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?)