[Python-modules-commits] [python-social-auth] 70/322: Link docs, apply PEP8, change quotes and code style
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:12:50 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 a84f6a1da55c1ca8f0f0ace7fc6ae046b194fda3
Author: Matías Aguirre <matiasaguirre at gmail.com>
Date: Fri Jan 2 04:45:26 2015 -0200
Link docs, apply PEP8, change quotes and code style
---
docs/backends/index.rst | 1 +
docs/backends/slack.rst | 10 +++++-----
social/backends/slack.py | 36 +++++++++++++++++-------------------
3 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/docs/backends/index.rst b/docs/backends/index.rst
index ae9afe5..262d68f 100644
--- a/docs/backends/index.rst
+++ b/docs/backends/index.rst
@@ -100,6 +100,7 @@ Social backends
salesforce
shopify
skyrock
+ slack
soundcloud
spotify
suse
diff --git a/docs/backends/slack.rst b/docs/backends/slack.rst
index 5c4be27..831a9de 100644
--- a/docs/backends/slack.rst
+++ b/docs/backends/slack.rst
@@ -1,11 +1,11 @@
Slack
-======
+=====
Slack
-- Register a new application at `https://api.slack.com/applications`_, set the callback URL to
- ``http://example.com/complete/slack/`` replacing ``example.com`` with your
- domain.
+- Register a new application at `https://api.slack.com/applications`_, set the
+ callback URL to ``http://example.com/complete/slack/`` replacing
+ ``example.com`` with your domain.
- Fill ``Client ID`` and ``Client Secret`` values in the settings::
@@ -16,4 +16,4 @@ Slack
SOCIAL_AUTH_SLACK_SCOPE = [...]
- See auth scopes at https://api.slack.com/docs/oauth
+ See auth scopes at https://api.slack.com/docs/oauth
diff --git a/social/backends/slack.py b/social/backends/slack.py
index 3f6eb0d..ec0446c 100644
--- a/social/backends/slack.py
+++ b/social/backends/slack.py
@@ -3,9 +3,10 @@ Slack OAuth2 backend, docs at:
http://psa.matiasaguirre.net/docs/backends/slack.html
https://api.slack.com/docs/oauth
"""
-from social.backends.oauth import BaseOAuth2
import re
+from social.backends.oauth import BaseOAuth2
+
class SlackOAuth2(BaseOAuth2):
"""Slack OAuth authentication backend"""
@@ -14,27 +15,26 @@ class SlackOAuth2(BaseOAuth2):
ACCESS_TOKEN_URL = 'https://slack.com/api/oauth.access'
ACCESS_TOKEN_METHOD = 'POST'
SCOPE_SEPARATOR = ','
+ REDIRECT_STATE = True
EXTRA_DATA = [
('id', 'id'),
('name', 'name'),
('real_name', 'real_name')
]
- REDIRECT_STATE = True
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("//([^.]+)\.slack\.com", response["team_url"])
- username = "%s@%s" % (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(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')
+ }
def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
@@ -48,13 +48,11 @@ class SlackOAuth2(BaseOAuth2):
# https://api.slack.com/methods/users.info
data = 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")
-
+ 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
--
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