[Python-modules-commits] [python-social-auth] 09/89: Add support for Drip Email Marketing Site
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:14:51 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.15
in repository python-social-auth.
commit 5e3b710c0c0a17f4fa79529b02bc89cf29cde805
Author: Buddy Lindsey, Jr <blindsey at summitesp.com>
Date: Sat Dec 26 15:04:19 2015 -0600
Add support for Drip Email Marketing Site
---
docs/backends/drip.rst | 13 +++++++++++++
social/backends/drip.py | 25 +++++++++++++++++++++++++
social/tests/backends/test_drip.py | 25 +++++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/docs/backends/drip.rst b/docs/backends/drip.rst
new file mode 100644
index 0000000..b09c64e
--- /dev/null
+++ b/docs/backends/drip.rst
@@ -0,0 +1,13 @@
+Drip
+=========
+
+Drip uses OAuth v2 for Authentication.
+
+- Register a new application with `Drip`_, and
+
+- fill ``Client ID`` and ``Client Secret`` from getdrip.com values in the settings::
+
+ SOCIAL_AUTH_DRIP_KEY = ''
+ SOCIAL_AUTH_DRIP_SECRET = ''
+
+.. _Drip: https://www.getdrip.com/user/applications
diff --git a/social/backends/drip.py b/social/backends/drip.py
new file mode 100644
index 0000000..af1f6b3
--- /dev/null
+++ b/social/backends/drip.py
@@ -0,0 +1,25 @@
+"""
+Drip OAuth2 backend, docs at:
+ http://psa.matiasaguirre.net/docs/backends/drip.html
+"""
+from social.backends.oauth import BaseOAuth2
+
+
+class DripOAuth(BaseOAuth2):
+ name = 'drip'
+ AUTHORIZATION_URL = 'https://www.getdrip.com/oauth/authorize'
+ ACCESS_TOKEN_URL = 'https://www.getdrip.com/oauth/token'
+ ACCESS_TOKEN_METHOD = 'POST'
+
+ def get_user_id(self, details, response):
+ return details['email']
+
+ def get_user_details(self, response):
+ return {'email': response['users'][0]['email'],
+ 'fullname': response['users'][0]['name'],
+ 'username': response['users'][0]['email']}
+
+ def user_data(self, access_token, *args, **kwargs):
+ return self.get_json(
+ 'https://api.getdrip.com/v2/user',
+ headers={'Authorization': 'Bearer {}'.format(access_token)})
diff --git a/social/tests/backends/test_drip.py b/social/tests/backends/test_drip.py
new file mode 100644
index 0000000..e9424ac
--- /dev/null
+++ b/social/tests/backends/test_drip.py
@@ -0,0 +1,25 @@
+import json
+
+from social.tests.backends.oauth import OAuth2Test
+
+
+class DripOAuthTest(OAuth2Test):
+ backend_path = 'social.backends.drip.DripOAuth'
+ user_data_url = 'https://api.getdrip.com/v2/user'
+ expected_username = 'other at example.com'
+ access_token_body = json.dumps({
+ "access_token": "822bbf7cd12243df",
+ "token_type": "bearer",
+ "scope": "public"
+ })
+
+ user_data_body = json.dumps(
+ {'users': [
+ {'email': 'other at example.com', 'name': None}
+ ]})
+
+ 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