[Python-modules-commits] [python-social-auth] 123/322: Add dribble backend.
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:12:57 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 e1d891b1a27d8acf3abe84e7f58fd2823b9e2694
Author: tell-k <ffk2005 at gmail.com>
Date: Sun Feb 15 02:33:16 2015 +0900
Add dribble backend.
---
docs/backends/dribbble.rst | 20 +++++++++++
social/backends/dribbble.py | 61 ++++++++++++++++++++++++++++++++++
social/tests/backends/test_dribbble.py | 26 +++++++++++++++
3 files changed, 107 insertions(+)
diff --git a/docs/backends/dribbble.rst b/docs/backends/dribbble.rst
new file mode 100644
index 0000000..0bf2b99
--- /dev/null
+++ b/docs/backends/dribbble.rst
@@ -0,0 +1,20 @@
+Dribbble
+========
+
+Dribbble
+
+- Register a new application at `https://dribbble.com/account/applications/new`_, set the
+ callback URL to ``http://example.com/complete/dribbble/`` replacing
+ ``example.com`` with your domain.
+
+- Fill ``Client ID`` and ``Client Secret`` values in the settings::
+
+ SOCIAL_AUTH_DRIBBBLE_KEY = ''
+ SOCIAL_AUTH_DRIBBBLE_SECRET = ''
+
+- Also it's possible to define extra permissions with::
+
+ SOCIAL_AUTH_DRIBBBLE_SCOPE = [...]
+
+ See auth scopes at http://developer.dribbble.com/v1/oauth/
+
diff --git a/social/backends/dribbble.py b/social/backends/dribbble.py
new file mode 100644
index 0000000..28d84b2
--- /dev/null
+++ b/social/backends/dribbble.py
@@ -0,0 +1,61 @@
+"""
+Dribbble OAuth2 backend, docs at:
+ http://psa.matiasaguirre.net/docs/backends/dribbble.html
+"""
+
+from social.backends.oauth import BaseOAuth2
+
+
+class DribbbleOAuth2(BaseOAuth2):
+ """Dribbble OAuth authentication backend"""
+ name = 'dribbble'
+ AUTHORIZATION_URL = 'https://dribbble.com/oauth/authorize'
+ ACCESS_TOKEN_URL = 'https://dribbble.com/oauth/token'
+ ACCESS_TOKEN_METHOD = 'POST'
+ SCOPE_SEPARATOR = ','
+ EXTRA_DATA = [
+ ('id', 'id'),
+ ('name', 'name'),
+ ('html_url', 'html_url'),
+ ('avatar_url', 'avatar_url'),
+ ('bio', 'bio'),
+ ('location', 'location'),
+ ('links', 'links'),
+ ('buckets_count', 'buckets_count'),
+ ('comments_received_count', 'comments_received_count'),
+ ('followers_count', 'followers_count'),
+ ('followings_count', 'followings_count'),
+ ('likes_count', 'likes_count'),
+ ('likes_received_count', 'likes_received_count'),
+ ('projects_count', 'projects_count')
+ ('rebounds_received_count', 'rebounds_received_count'),
+ ('shots_count', 'shots_count'),
+ ('teams_count', 'teams_count'),
+ ('pro', 'pro'),
+ ('buckets_url', 'buckets_url'),
+ ('followers_url', 'followers_url'),
+ ('following_url', 'following_url'),
+ ('likes_url', 'shots_url'),
+ ('teams_url', 'teams_url'),
+ ('created_at', 'created_at'),
+ ('updated_at', 'updated_at'),
+ ]
+
+ def get_user_details(self, response):
+ """Return user details from Dribbble account"""
+ fullname, first_name, last_name = self.get_user_names(
+ response.get('name')
+ )
+ return {'username': response.get('username'),
+ 'email': response.get('email', ''),
+ 'fullname': fullname,
+ 'first_name': first_name,
+ 'last_name': last_name}
+
+ def user_data(self, access_token, *args, **kwargs):
+ """Loads user data from service"""
+ return self.get_json(
+ 'https://api.dribbble.com/v1/user',
+ headers={
+ 'Authorization': ' Bearer {0}'.format(access_token)
+ })
diff --git a/social/tests/backends/test_dribbble.py b/social/tests/backends/test_dribbble.py
new file mode 100644
index 0000000..0abe86c
--- /dev/null
+++ b/social/tests/backends/test_dribbble.py
@@ -0,0 +1,26 @@
+import json
+
+from social.tests.backends.oauth import OAuth2Test
+
+
+class DribbbleOAuth2Test(OAuth2Test):
+ backend_path = 'social.backends.dribbble.DribbbleOAuth2'
+ user_data_url = 'https://api.dribbble.com/v1/user'
+ expected_username = 'foobar'
+
+ access_token_body = json.dumps({
+ 'access_token': 'foobar',
+ 'token_type': 'bearer'
+ })
+
+ user_data_body = json.dumps({
+ 'id': 'foobar',
+ 'username': 'foobar',
+ 'name': 'Foo Bar'
+ })
+
+ def test_login(self):
+ self.do_login()
+
+ def test_partial_pipeline(self):
+ self.do_partial_pipeline()
--
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