[Python-modules-commits] [python-social-auth] 115/322: Merge branch 'slack' of https://github.com/gorillamania/python-social-auth into gorillamania-slack

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:12:56 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 c994d11b6f1d9c036f19871b2a23eaffacd607d4
Merge: 5c9c9f9 d46aa12
Author: Matías Aguirre <matiasaguirre at gmail.com>
Date:   Tue Feb 10 00:16:24 2015 -0200

    Merge branch 'slack' of https://github.com/gorillamania/python-social-auth into gorillamania-slack
    
    Conflicts:
    	social/backends/slack.py

 social/backends/slack.py | 42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --cc social/backends/slack.py
index ec0446c,bbf51cd..f1e439b
--- a/social/backends/slack.py
+++ b/social/backends/slack.py
@@@ -24,35 -22,46 +24,41 @@@ class SlackOAuth2(BaseOAuth2)
  
      def get_user_details(self, response):
          """Return user details from Slack account"""
 -
          # Build the username with the team $username@$team_url
          # Necessary to get unique names for all of slack
-         match = re.search(r'//([^.]+)\.slack\.com', response['team_url'])
-         username = '{0}@{1}'.format(response.get('name'), match.group(1))
-         return {
-             'username': username,
-             'email': response['profile'].get('email', ''),
-             'fullname': response['profile'].get('real_name'),
-             'first_name': response['profile'].get('first_name'),
-             'last_name': response['profile'].get('last_name')
-         }
 -        match = re.search("//([^.]+)\.slack\.com", response["url"])
 -        username = "%s@%s" % (response.get("user"), match.group(1))
++        match = re.search(r'//([^.]+)\.slack\.com', response['url'])
++        username = '{0}@{1}'.format(response.get("user"), match.group(1))
+ 
+         out = {'username': username}
 -        if response.get("profile"):
++        if 'profile' in response:
+             out.update({
 -                'email': response["profile"].get("email"),
 -                'fullname': response["profile"].get("real_name"),
 -                'first_name': response["profile"].get("first_name"),
 -                'last_name': response["profile"].get("last_name")
++                'email': response['profile'].get('email'),
++                'fullname': response['profile'].get('real_name'),
++                'first_name': response['profile'].get('first_name'),
++                'last_name': response['profile'].get('last_name')
+             })
+         return out
  
      def user_data(self, access_token, *args, **kwargs):
          """Loads user data from service"""
          # Has to be two calls, because the users.info requires a username,
--        # And we want the team information
--        # https://api.slack.com/methods/auth.test
++        # And we want the team information. Check auth.test details at:
++        #   https://api.slack.com/methods/auth.test
          auth_test = self.get_json('https://slack.com/api/auth.test', params={
              'token': access_token
          })
 -        out = auth_test
 -        del out["ok"]
  
          # https://api.slack.com/methods/users.info
-         data = self.get_json('https://slack.com/api/users.info', params={
+         user_info = self.get_json('https://slack.com/api/users.info', params={
              'token': access_token,
 -            'user': auth_test.get("user_id")
 +            'user': auth_test.get('user_id')
          })
-         # Inject the team data
-         out = data['user'].copy()
-         out['team_id'] = auth_test.get('team_id')
-         out['team'] = auth_test.get('team')
-         out['team_url'] = auth_test.get('url')
-         return out
 -
 -        if user_info.get("user"):
++        if user_info.get('user'):
+             # Capture the user data, if available based on the scope
 -            out.update(user_info["user"])
++            auth_test.update(user_info['user'])
+ 
+         # Clean up user_id vs id
 -        out["id"] = out["user_id"]
 -        del out["user_id"]
 -
 -        return out
++        auth_test['id'] = auth_test['user_id']
++        auth_test.pop('ok', None)
++        auth_test.pop('user_id', None)
++        return auth_test

-- 
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