[Python-modules-commits] [python-social-auth] 05/61: Added Meetup.com OAuth2 backend

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:14:01 UTC 2016


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to tag v0.2.13
in repository python-social-auth.

commit 204da39f8c20164ae3670bace036a279b2db0fb6
Author: bluszcz <bluszcz at bluszcz.net>
Date:   Mon Jul 13 02:10:49 2015 +0200

    Added Meetup.com OAuth2 backend
---
 docs/backends/meetup.rst  | 14 ++++++++++++++
 social/backends/meetup.py | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/docs/backends/meetup.rst b/docs/backends/meetup.rst
new file mode 100644
index 0000000..558c3ad
--- /dev/null
+++ b/docs/backends/meetup.rst
@@ -0,0 +1,14 @@
+Meetup
+======
+
+Meetup.com uses OAuth2 for its auth mechanism.
+
+- Register a new OAuth Consumer at `Meetup Consumer Registration`_, set your
+  consumer name, redirect uri.
+
+- Fill ``key`` and ``secret`` values in the settings::
+
+      SOCIAL_AUTH_MEETUP_KEY = ''
+      SOCIAL_AUTH_MEETUP_SECRET = ''
+
+.. _Meetup Consumer Registration: https://secure.meetup.com/meetup_api/oauth_consumers/create
diff --git a/social/backends/meetup.py b/social/backends/meetup.py
new file mode 100644
index 0000000..b2e8d46
--- /dev/null
+++ b/social/backends/meetup.py
@@ -0,0 +1,41 @@
+"""
+Meetup OAuth2 backend, docs at:
+    http://psa.matiasaguirre.net/docs/backends/soundcloud.html
+"""
+from social.p3 import urlencode
+from social.backends.oauth import BaseOAuth2
+
+
+class MeetupOAuth2(BaseOAuth2):
+    """Meetup OAuth2 authentication backend"""
+    name = 'meetup'
+    AUTHORIZATION_URL = 'https://secure.meetup.com/oauth2/authorize'
+    ACCESS_TOKEN_URL = 'https://secure.meetup.com/oauth2/access'
+    ACCESS_TOKEN_METHOD = 'POST'
+    DEFAULT_SCOPE = ['basic',]
+    SCOPE_SEPARATOR = ','
+    REDIRECT_STATE = False
+    EXTRA_DATA = [
+        ('id', 'id'),
+        ('refresh_token', 'refresh_token'),
+        ('expires', 'expires')
+    ]
+    STATE_PARAMETER = 'state'
+
+    def get_user_details(self, response):
+        """Return user details from Meetup account"""
+        fullname, first_name, last_name = self.get_user_names(
+            response.get('name')
+        )
+
+        return {'username': response.get('username'),
+                'email': response.get('email') or '',
+                '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.meetup.com/2/member/self',
+                             params={'access_token': access_token})
+

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