[Python-modules-commits] [python-social-auth] 169/322: Add wunderlist oauth2 backend

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:13:04 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 829806fd36e45e6e0ccf8fcd364f7cac91da5b9f
Author: Adam Bogdał <adam at bogdal.pl>
Date:   Tue Mar 10 20:53:02 2015 +0100

    Add wunderlist oauth2 backend
---
 docs/backends/index.rst                            |  1 +
 docs/backends/wunderlist.rst                       | 13 ++++++++++
 docs/intro.rst                                     |  2 ++
 .../cherrypy_example/local_settings.py.template    |  1 +
 examples/django_example/example/settings.py        |  1 +
 examples/django_me_example/example/settings.py     |  1 +
 examples/flask_example/settings.py                 |  1 +
 examples/flask_me_example/settings.py              |  1 +
 examples/pyramid_example/example/settings.py       |  1 +
 examples/tornado_example/settings.py               |  1 +
 examples/webpy_example/app.py                      |  1 +
 social/backends/wunderlist.py                      | 29 ++++++++++++++++++++++
 social/tests/backends/test_wunderlist.py           | 26 +++++++++++++++++++
 13 files changed, 79 insertions(+)

diff --git a/docs/backends/index.rst b/docs/backends/index.rst
index 6af6473..0b4b3b4 100644
--- a/docs/backends/index.rst
+++ b/docs/backends/index.rst
@@ -121,6 +121,7 @@ Social backends
    vimeo
    vk
    weibo
+   wunderlist
    xing
    yahoo
    yammer
diff --git a/docs/backends/wunderlist.rst b/docs/backends/wunderlist.rst
new file mode 100644
index 0000000..218686d
--- /dev/null
+++ b/docs/backends/wunderlist.rst
@@ -0,0 +1,13 @@
+Wunderlist
+==========
+
+Wunderlist uses OAuth v2 for Authentication.
+
+- Register a new application at `Wunderlist Developer Portal`_, and
+
+- fill ``Client Id`` and ``Client Secret`` values in the settings::
+
+      SOCIAL_AUTH_WUNDERLIST_KEY = ''
+      SOCIAL_AUTH_WUNDERLIST_SECRET = ''
+
+.. _Wunderlist Developer Portal: https://developer.wunderlist.com/applications
diff --git a/docs/intro.rst b/docs/intro.rst
index 8e12826..712f6db 100644
--- a/docs/intro.rst
+++ b/docs/intro.rst
@@ -82,6 +82,7 @@ or extend current one):
     * Vimeo_ OAuth1
     * VK.com_ OpenAPI, OAuth2 and OAuth2 for Applications
     * Weibo_ OAuth2
+    * Wunderlist_ OAuth2
     * Xing_ OAuth1
     * Yahoo_ OpenId and OAuth1
     * Yammer_ OAuth2
@@ -153,6 +154,7 @@ section.
 .. _Twitter: http://twitter.com
 .. _VK.com: http://vk.com
 .. _Weibo: http://weibo.com
+.. _Wunderlist: http://wunderlist.com
 .. _Xing: https://www.xing.com
 .. _Yahoo: http://yahoo.com
 .. _Yammer: https://www.yammer.com
diff --git a/examples/cherrypy_example/local_settings.py.template b/examples/cherrypy_example/local_settings.py.template
index 919e8ea..e9fe9c0 100644
--- a/examples/cherrypy_example/local_settings.py.template
+++ b/examples/cherrypy_example/local_settings.py.template
@@ -38,6 +38,7 @@ SOCIAL_SETTINGS = {
         'social.backends.yandex.YandexOAuth2',
         'social.backends.podio.PodioOAuth2',
         'social.backends.reddit.RedditOAuth2',
+        'social.backends.wunderlist.WunderlistOAuth2',
     ),
     'SOCIAL_AUTH_GOOGLE_OAUTH2_KEY': '',
     'SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET': ''
diff --git a/examples/django_example/example/settings.py b/examples/django_example/example/settings.py
index a66aaec..fff53dc 100644
--- a/examples/django_example/example/settings.py
+++ b/examples/django_example/example/settings.py
@@ -189,6 +189,7 @@ AUTHENTICATION_BACKENDS = (
     'social.backends.twitter.TwitterOAuth',
     'social.backends.vk.VKOAuth2',
     'social.backends.weibo.WeiboOAuth2',
+    'social.backends.wunderlist.WunderlistOAuth2',
     'social.backends.xing.XingOAuth',
     'social.backends.yahoo.YahooOAuth',
     'social.backends.yahoo.YahooOpenId',
diff --git a/examples/django_me_example/example/settings.py b/examples/django_me_example/example/settings.py
index caee14a..9c2a157 100644
--- a/examples/django_me_example/example/settings.py
+++ b/examples/django_me_example/example/settings.py
@@ -180,6 +180,7 @@ AUTHENTICATION_BACKENDS = (
     'social.backends.amazon.AmazonOAuth2',
     'social.backends.email.EmailAuth',
     'social.backends.username.UsernameAuth',
+    'social.backends.wunderlist.WunderlistOAuth2',
     'django.contrib.auth.backends.ModelBackend',
 )
 
diff --git a/examples/flask_example/settings.py b/examples/flask_example/settings.py
index 9f830f8..8e0df5e 100644
--- a/examples/flask_example/settings.py
+++ b/examples/flask_example/settings.py
@@ -51,4 +51,5 @@ SOCIAL_AUTH_AUTHENTICATION_BACKENDS = (
     'social.backends.podio.PodioOAuth2',
     'social.backends.reddit.RedditOAuth2',
     'social.backends.mineid.MineIDOAuth2',
+    'social.backends.wunderlist.WunderlistOAuth2',
 )
diff --git a/examples/flask_me_example/settings.py b/examples/flask_me_example/settings.py
index fe9fb01..26d9c5c 100644
--- a/examples/flask_me_example/settings.py
+++ b/examples/flask_me_example/settings.py
@@ -57,4 +57,5 @@ SOCIAL_AUTH_AUTHENTICATION_BACKENDS = (
     'social.backends.podio.PodioOAuth2',
     'social.backends.reddit.RedditOAuth2',
     'social.backends.mineid.MineIDOAuth2',
+    'social.backends.wunderlist.WunderlistOAuth2',
 )
diff --git a/examples/pyramid_example/example/settings.py b/examples/pyramid_example/example/settings.py
index 5b2b8e2..224917f 100644
--- a/examples/pyramid_example/example/settings.py
+++ b/examples/pyramid_example/example/settings.py
@@ -45,6 +45,7 @@ SOCIAL_AUTH_SETTINGS = {
         'social.backends.podio.PodioOAuth2',
         'social.backends.reddit.RedditOAuth2',
         'social.backends.mineid.MineIDOAuth2',
+        'social.backends.wunderlist.WunderlistOAuth2',
     )
 }
 
diff --git a/examples/tornado_example/settings.py b/examples/tornado_example/settings.py
index 3d4d0da..e7e4742 100644
--- a/examples/tornado_example/settings.py
+++ b/examples/tornado_example/settings.py
@@ -44,6 +44,7 @@ SOCIAL_AUTH_AUTHENTICATION_BACKENDS = (
     'social.backends.podio.PodioOAuth2',
     'social.backends.reddit.RedditOAuth2',
     'social.backends.mineid.MineIDOAuth2',
+    'social.backends.wunderlist.WunderlistOAuth2',
 )
 
 from local_settings import *
diff --git a/examples/webpy_example/app.py b/examples/webpy_example/app.py
index 354a513..47d76c4 100644
--- a/examples/webpy_example/app.py
+++ b/examples/webpy_example/app.py
@@ -56,6 +56,7 @@ web.config[setting_name('AUTHENTICATION_BACKENDS')] = (
     'social.backends.yandex.YandexOAuth2',
     'social.backends.podio.PodioOAuth2',
     'social.backends.mineid.MineIDOAuth2',
+    'social.backends.wunderlist.WunderlistOAuth2',
 )
 web.config[setting_name('LOGIN_REDIRECT_URL')] = '/done/'
 
diff --git a/social/backends/wunderlist.py b/social/backends/wunderlist.py
new file mode 100644
index 0000000..9e39628
--- /dev/null
+++ b/social/backends/wunderlist.py
@@ -0,0 +1,29 @@
+from social.backends.oauth import BaseOAuth2
+
+
+class WunderlistOAuth2(BaseOAuth2):
+    """Wunderlist OAuth2 authentication backend"""
+    name = 'wunderlist'
+    AUTHORIZATION_URL = 'https://www.wunderlist.com/oauth/authorize'
+    ACCESS_TOKEN_URL = 'https://www.wunderlist.com/oauth/access_token'
+    ACCESS_TOKEN_METHOD = 'POST'
+    REDIRECT_STATE = False
+
+    def get_user_details(self, response):
+        """Return user details from Wunderlist account"""
+        fullname, first_name, last_name = self.get_user_names(
+            response.get('name')
+        )
+        return {'username': str(response.get('id')),
+                '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"""
+        headers = {
+            'X-Access-Token': access_token,
+            'X-Client-ID': self.setting('KEY')}
+        return self.get_json(
+            'https://a.wunderlist.com/api/v1/user', headers=headers)
diff --git a/social/tests/backends/test_wunderlist.py b/social/tests/backends/test_wunderlist.py
new file mode 100644
index 0000000..0f16cfd
--- /dev/null
+++ b/social/tests/backends/test_wunderlist.py
@@ -0,0 +1,26 @@
+import json
+
+from social.tests.backends.oauth import OAuth2Test
+
+
+class WunderlistOAuth2Test(OAuth2Test):
+    backend_path = 'social.backends.wunderlist.WunderlistOAuth2'
+    user_data_url = 'https://a.wunderlist.com/api/v1/user'
+    expected_username = '12345'
+    access_token_body = json.dumps({
+        'access_token': 'foobar-token',
+        'token_type': 'foobar'})
+    user_data_body = json.dumps({
+        'created_at': '2015-01-21T00:56:51.442Z',
+        'email': 'foo at bar.com',
+        'id': 12345,
+        'name': 'foobar',
+        'revision': 1,
+        'type': 'user',
+        'updated_at': '2015-01-21T00:56:51.442Z'})
+
+    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