[Python-modules-commits] [python-social-auth] 270/322: ChangeTip backend

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:13:18 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 acbbf93e2177e5e0b252035355f9495e8ed6c4b3
Author: Nick Sullivan <nick at sullivanflock.com>
Date:   Fri Apr 17 15:40:26 2015 -0700

    ChangeTip backend
---
 social/backends/changetip.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/social/backends/changetip.py b/social/backends/changetip.py
new file mode 100644
index 0000000..75e043d
--- /dev/null
+++ b/social/backends/changetip.py
@@ -0,0 +1,29 @@
+from social.backends.oauth import BaseOAuth2
+from urllib import urlencode, urlopen
+import json
+
+
+class ChangeTipOAuth2(BaseOAuth2):
+    """ChangeTip OAuth authentication backend
+       https://www.changetip.com/api
+    """
+    name = 'changetip'
+    AUTHORIZATION_URL = 'https://www.changetip.com/o/authorize/'
+    ACCESS_TOKEN_URL = 'https://www.changetip.com/o/token/'
+    ACCESS_TOKEN_METHOD = 'POST'
+    SCOPE_SEPARATOR = ' '
+
+    def get_user_details(self, response):
+        """Return user details from ChangeTip account"""
+        return {'username': response['username'],
+                'email': response['email'] or ''}
+
+    def user_data(self, access_token, *args, **kwargs):
+        """Loads user data from service"""
+        url = 'https://www.changetip.com/v2/me/?' + urlencode({
+            'access_token': access_token
+        })
+        try:
+            return json.load(urlopen(url))
+        except ValueError:
+            return None

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