diff options
author | Pat Ferate <pferate+github@gmail.com> | 2016-07-08 09:10:16 -0700 |
---|---|---|
committer | Pat Ferate <pferate+github@gmail.com> | 2016-07-08 10:26:07 -0700 |
commit | 5ef8bb0950b62ba18b9c05344cdf32aca5671e2f (patch) | |
tree | 20efee4b76cbaaafa56fbd8fb9950c47f4966fd7 | |
parent | 9f9dbc22f1a7dac3cf7dcf8469525a55134363d8 (diff) | |
download | oauth2client-5ef8bb0950b62ba18b9c05344cdf32aca5671e2f.tar.gz |
Resolve lines over 80 characters
-rw-r--r-- | oauth2client/client.py | 10 | ||||
-rw-r--r-- | oauth2client/contrib/django_util/__init__.py | 18 | ||||
-rw-r--r-- | oauth2client/contrib/django_util/views.py | 3 | ||||
-rw-r--r-- | oauth2client/contrib/gce.py | 3 | ||||
-rw-r--r-- | oauth2client/service_account.py | 13 | ||||
-rw-r--r-- | tests/contrib/test_gce.py | 12 | ||||
-rw-r--r-- | tests/test_client.py | 3 | ||||
-rw-r--r-- | tests/test_service_account.py | 6 |
8 files changed, 41 insertions, 27 deletions
diff --git a/oauth2client/client.py b/oauth2client/client.py index a0e4473..97ac3e6 100644 --- a/oauth2client/client.py +++ b/oauth2client/client.py @@ -257,8 +257,8 @@ class Credentials(object): strip: array, An array of names of members to exclude from the JSON. to_serialize: dict, (Optional) The properties for this object - that will be serialized. This allows callers to modify - before serializing. + that will be serialized. This allows callers to + modify before serializing. Returns: string, a JSON representation of this instance, suitable to pass to @@ -357,7 +357,8 @@ class Storage(object): Args: lock: An optional threading.Lock-like object. Must implement at - least acquire() and release(). Does not need to be re-entrant. + least acquire() and release(). Does not need to be + re-entrant. """ self._lock = lock @@ -2209,7 +2210,8 @@ def flow_from_clientsecrets(filename, scope, redirect_uri=None, except clientsecrets.InvalidClientSecretsError as e: if message is not None: if e.args: - message = 'The client secrets were invalid: \n{0}\n{1}'.format(e, message) + message = ('The client secrets were invalid: ' + '\n{0}\n{1}'.format(e, message)) sys.exit(message) else: raise diff --git a/oauth2client/contrib/django_util/__init__.py b/oauth2client/contrib/django_util/__init__.py index 19ac8b4..4ede05b 100644 --- a/oauth2client/contrib/django_util/__init__.py +++ b/oauth2client/contrib/django_util/__init__.py @@ -15,10 +15,10 @@ """Utilities for the Django web framework Provides Django views and helpers the make using the OAuth2 web server -flow easier. It includes an ``oauth_required`` decorator to automatically ensure -that user credentials are available, and an ``oauth_enabled`` decorator to check -if the user has authorized, and helper shortcuts to create the authorization -URL otherwise. +flow easier. It includes an ``oauth_required`` decorator to automatically +ensure that user credentials are available, and an ``oauth_enabled`` decorator +to check if the user has authorized, and helper shortcuts to create the +authorization URL otherwise. Only Django versions 1.8+ are supported. @@ -89,8 +89,8 @@ Add the oauth2 routes to your application's urls.py urlpatterns. urlpatterns += [url(r'^oauth2/', include(oauth2_urls))] To require OAuth2 credentials for a view, use the `oauth2_required` decorator. -This creates a credentials object with an id_token, and allows you to create an -`http` object to build service clients with. These are all attached to the +This creates a credentials object with an id_token, and allows you to create +an `http` object to build service clients with. These are all attached to the request.oauth .. code-block:: python @@ -202,9 +202,9 @@ def _get_oauth2_client_id_and_secret(settings_instance): return client_id, client_secret else: raise exceptions.ImproperlyConfigured( - "Must specify either GOOGLE_OAUTH2_CLIENT_SECRETS_JSON, or " - " both GOOGLE_OAUTH2_CLIENT_ID and GOOGLE_OAUTH2_CLIENT_SECRET " - "in settings.py") + "Must specify either GOOGLE_OAUTH2_CLIENT_SECRETS_JSON, or " + "both GOOGLE_OAUTH2_CLIENT_ID and " + "GOOGLE_OAUTH2_CLIENT_SECRET in settings.py") class OAuth2Settings(object): diff --git a/oauth2client/contrib/django_util/views.py b/oauth2client/contrib/django_util/views.py index 0d5561c..523e479 100644 --- a/oauth2client/contrib/django_util/views.py +++ b/oauth2client/contrib/django_util/views.py @@ -87,7 +87,8 @@ def oauth2_callback(request): try: server_csrf = request.session[_CSRF_KEY] except KeyError: - return http.HttpResponseBadRequest("No existing session for this flow.") + return http.HttpResponseBadRequest( + "No existing session for this flow.") try: state = json.loads(encoded_state) diff --git a/oauth2client/contrib/gce.py b/oauth2client/contrib/gce.py index b495e44..cccf495 100644 --- a/oauth2client/contrib/gce.py +++ b/oauth2client/contrib/gce.py @@ -112,7 +112,8 @@ class AppAssertionCredentials(AssertionCredentials): """ if self.invalid: info = _metadata.get_service_account_info( - http_request, service_account=self.service_account_email or 'default') + http_request, + service_account=self.service_account_email or 'default') self.invalid = False self.service_account_email = info['email'] self.scopes = info['scopes'] diff --git a/oauth2client/service_account.py b/oauth2client/service_account.py index 33fff4e..8cc3505 100644 --- a/oauth2client/service_account.py +++ b/oauth2client/service_account.py @@ -134,8 +134,8 @@ class ServiceAccountCredentials(AssertionCredentials): strip: array, An array of names of members to exclude from the JSON. to_serialize: dict, (Optional) The properties for this object - that will be serialized. This allows callers to modify - before serializing. + that will be serialized. This allows callers to + modify before serializing. Returns: string, a JSON representation of this instance, suitable to pass to @@ -507,7 +507,8 @@ class ServiceAccountCredentials(AssertionCredentials): Returns: ServiceAccountCredentials, a copy of the current service account - credentials with updated claims to use when obtaining access tokens. + credentials with updated claims to use when obtaining access + tokens. """ new_kwargs = dict(self._kwargs) new_kwargs.update(claims) @@ -603,7 +604,8 @@ class _JWTAccessCredentials(ServiceAccountCredentials): h = credentials.authorize(h) """ request_orig = http.request - request_auth = super(_JWTAccessCredentials, self).authorize(http).request + request_auth = super(_JWTAccessCredentials, + self).authorize(http).request # The closure that will replace 'httplib2.Http.request'. def new_request(uri, method='GET', body=None, headers=None, @@ -691,7 +693,8 @@ class _JWTAccessCredentials(ServiceAccountCredentials): def _create_token(self, additional_claims=None): now = _UTCNOW() - expiry = now + datetime.timedelta(seconds=self._MAX_TOKEN_LIFETIME_SECS) + lifetime = datetime.timedelta(seconds=self._MAX_TOKEN_LIFETIME_SECS) + expiry = now + lifetime payload = { 'iat': _datetime_to_secs(now), 'exp': _datetime_to_secs(expiry), diff --git a/tests/contrib/test_gce.py b/tests/contrib/test_gce.py index 49d7599..bacecca 100644 --- a/tests/contrib/test_gce.py +++ b/tests/contrib/test_gce.py @@ -79,11 +79,13 @@ class AppAssertionCredentialsTests(unittest2.TestCase): credentials.get_access_token(http=http_mock) self.assertEqual(credentials.access_token, 'A') self.assertTrue(credentials.access_token_expired) - get_token.assert_called_with(http_request, service_account='a@example.com') + get_token.assert_called_with(http_request, + service_account='a@example.com') credentials.get_access_token(http=http_mock) self.assertEqual(credentials.access_token, 'B') self.assertFalse(credentials.access_token_expired) - get_token.assert_called_with(http_request, service_account='a@example.com') + get_token.assert_called_with(http_request, + service_account='a@example.com') get_info.assert_not_called() def test_refresh_token_failed_fetch(self): @@ -125,7 +127,8 @@ class AppAssertionCredentialsTests(unittest2.TestCase): self.assertFalse(credentials.invalid) credentials.retrieve_scopes(http_mock) # Assert scopes weren't refetched - metadata.assert_called_once_with(http_request, service_account='default') + metadata.assert_called_once_with(http_request, + service_account='default') @mock.patch('oauth2client.contrib._metadata.get_service_account_info', side_effect=httplib2.HttpLib2Error('No Such Email')) @@ -136,7 +139,8 @@ class AppAssertionCredentialsTests(unittest2.TestCase): with self.assertRaises(httplib2.HttpLib2Error): credentials.retrieve_scopes(http_mock) - metadata.assert_called_once_with(http_request, service_account='b@example.com') + metadata.assert_called_once_with(http_request, + service_account='b@example.com') def test_save_to_well_known_file(self): import os diff --git a/tests/test_client.py b/tests/test_client.py index 3a2a20a..a8feb19 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -2149,7 +2149,8 @@ class FlowFromCachedClientsecrets(unittest2.TestCase): filename = object() cache = object() message = 'hi mom' - expected = 'The client secrets were invalid: \n{0}\n{1}'.format('foobar', 'hi mom') + expected = ('The client secrets were invalid: ' + '\n{0}\n{1}'.format('foobar', 'hi mom')) flow_from_clientsecrets(filename, None, cache=cache, message=message) sys_exit.assert_called_once_with(expected) diff --git a/tests/test_service_account.py b/tests/test_service_account.py index d9e08f9..1548632 100644 --- a/tests/test_service_account.py +++ b/tests/test_service_account.py @@ -179,12 +179,14 @@ class ServiceAccountCredentialsTests(unittest2.TestCase): for creds in (creds_from_filename, creds_from_file_contents): self.assertIsInstance(creds, ServiceAccountCredentials) self.assertIsNone(creds.client_id) - self.assertEqual(creds._service_account_email, service_account_email) + self.assertEqual(creds._service_account_email, + service_account_email) self.assertIsNone(creds._private_key_id) self.assertIsNone(creds._private_key_pkcs8_pem) self.assertEqual(creds._private_key_pkcs12, key_contents) if private_key_password is not None: - self.assertEqual(creds._private_key_password, private_key_password) + self.assertEqual(creds._private_key_password, + private_key_password) self.assertEqual(creds._scopes, ' '.join(scopes)) self.assertEqual(creds.token_uri, token_uri) self.assertEqual(creds.revoke_uri, revoke_uri) |