[Python-modules-commits] [python-social-auth] 310/322: PEP8

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:13:23 UTC 2016


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to tag v0.2.10
in repository python-social-auth.

commit 0c0eb172b240774d254436ccfdd6e5c39da151df
Author: Matías Aguirre <matiasaguirre at gmail.com>
Date:   Fri May 29 13:28:14 2015 -0300

    PEP8
---
 docs/backends/azuread.rst  | 11 ++++++-----
 social/backends/azuread.py | 34 +++++++++++-----------------------
 2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/docs/backends/azuread.rst b/docs/backends/azuread.rst
index 8ec2457..6c84c5c 100644
--- a/docs/backends/azuread.rst
+++ b/docs/backends/azuread.rst
@@ -1,10 +1,10 @@
 Microsoft Azure Active Directory
-======
+================================
 
 To enable OAuth2 support:
 
-- Fill in ``Client ID`` and ``Client Secret`` settings. These values can be obtained
-  easily as described in `Azure AD Application Registration`_ doc::
+- Fill in ``Client ID`` and ``Client Secret`` settings. These values can be
+  obtained easily as described in `Azure AD Application Registration`_ doc::
 
       SOCIAL_AUTH_AZUREAD_OAUTH2_KEY = ''
       SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET = ''
@@ -13,7 +13,8 @@ To enable OAuth2 support:
 
       SOCIAL_AUTH_AZUREAD_OAUTH2_RESOURCE = ''
 
-      This is the resource you would like to access after authentication succeeds. 
-      Some of the possible values are: ``https://graph.windows.net`` or ``https://<your Sharepoint site name>-my.sharepoint.com``.
+  This is the resource you would like to access after authentication succeeds.
+  Some of the possible values are: ``https://graph.windows.net`` or
+  ``https://<your Sharepoint site name>-my.sharepoint.com``.
 
 .. _Azure AD Application Registration: https://msdn.microsoft.com/en-us/library/azure/dn132599.aspx
diff --git a/social/backends/azuread.py b/social/backends/azuread.py
index 33e820d..a015a0f 100644
--- a/social/backends/azuread.py
+++ b/social/backends/azuread.py
@@ -1,7 +1,7 @@
 """
 Copyright (c) 2015 Microsoft Open Technologies, Inc.
 
-All rights reserved. 
+All rights reserved.
 
 MIT License
 
@@ -28,16 +28,13 @@ SOFTWARE.
 Azure AD OAuth2 backend, docs at:
     http://psa.matiasaguirre.net/docs/backends/azuread.html
 """
-import datetime
-from calendar import timegm
-from social.exceptions import AuthException, AuthFailed, AuthCanceled, \
-                              AuthUnknownError, AuthMissingParameter, \
-                              AuthTokenError
+import time
+
 from jwt import DecodeError, ExpiredSignature, decode as jwt_decode
+
+from social.exceptions import AuthTokenError
 from social.backends.oauth import BaseOAuth2
-import requests
-import time
-import urllib
+
 
 class AzureADOAuth2(BaseOAuth2):
     name = 'azuread-oauth2'
@@ -79,12 +76,10 @@ class AzureADOAuth2(BaseOAuth2):
     def user_data(self, access_token, *args, **kwargs):
         response = kwargs.get('response')
         id_token = response.get('id_token')
-        
         try:
             decoded_id_token = jwt_decode(id_token, verify=False)
         except (DecodeError, ExpiredSignature) as de:
             raise AuthTokenError(self, de)
-        
         return decoded_id_token
 
     def auth_extra_arguments(self):
@@ -92,18 +87,15 @@ class AzureADOAuth2(BaseOAuth2):
         overriden by GET parameters."""
         extra_arguments = {}
         resource = self.setting('RESOURCE')
-        
         if resource:
-            extra_arguments = {
-                'resource': resource
-            }
-        
+            extra_arguments = {'resource': resource}
         return extra_arguments
 
     def extra_data(self, user, uid, response, details=None, *args, **kwargs):
         """Return access_token and extra defined names to store in
         extra_data field"""
-        data = super(AzureADOAuth2, self).extra_data(user, uid, response,details, *args, **kwargs)
+        data = super(AzureADOAuth2, self).extra_data(user, uid, response,
+            details, *args, **kwargs)
         data['resource'] = self.setting('RESOURCE')
         return data
 
@@ -115,16 +107,12 @@ class AzureADOAuth2(BaseOAuth2):
         }
 
     def get_auth_token(self, user_id):
-        """Return the access token for the given user, after ensuring that it has not expired, 
-        or refreshing it if so."""
+        """Return the access token for the given user, after ensuring that it
+        has not expired, or refreshing it if so."""
         user = self.get_user(user_id=user_id)
-
         access_token = user.social_user.access_token
         expires_on = user.social_user.extra_data['expires_on']
-
         if expires_on <= int(time.time()):
             new_token_response = self.refresh_token(token=access_token)
             access_token = new_token_response['access_token']
-
         return access_token
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-social-auth.git



More information about the Python-modules-commits mailing list