[Python-modules-commits] [python-social-auth] 27/322: Added Zotero OAuth1 backend

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:12:45 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 3b9910339887d0aeaedfb3e22752b499beb22190
Author: Miguel Paolino <miguel.paolino at datakin.io>
Date:   Fri Nov 7 16:42:37 2014 -0200

    Added Zotero OAuth1 backend
---
 docs/backends/zotero.rst  | 25 +++++++++++++++++++++++++
 social/backends/zotero.py | 31 +++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/docs/backends/zotero.rst b/docs/backends/zotero.rst
new file mode 100644
index 0000000..0a8330e
--- /dev/null
+++ b/docs/backends/zotero.rst
@@ -0,0 +1,25 @@
+Zotero
+======
+
+Zotero implements OAuth1 as their authentication mechanism for their Web API v3.
+
+
+1. Go to the `Zotero app registration page`_ to register your application.
+
+2. Fill the **Client ID** and **Client Secret** in your project settings::
+
+    SOCIAL_AUTH_ZOTERO_KEY = '...'
+    SOCIAL_AUTH_ZOTERO_SECRET = '...'
+
+3. Enable the backend::
+
+    SOCIAL_AUTH_AUTHENTICATION_BACKENDS = (
+        ...
+        'social.backends.amazon.Zotero',
+        ...
+    )
+
+Further documentation at `Zotero Web API v3 page`_.
+
+.. _Zotero app registration page: https://www.zotero.org/oauth/apps
+.. _Zotero Web API v3 page: https://www.zotero.org/support/dev/web_api/v3/start
diff --git a/social/backends/zotero.py b/social/backends/zotero.py
new file mode 100644
index 0000000..427e74b
--- /dev/null
+++ b/social/backends/zotero.py
@@ -0,0 +1,31 @@
+"""
+Zotero OAuth1 backends, docs at:
+    http://psa.matiasaguirre.net/docs/backends/zotero.html
+"""
+from requests import HTTPError
+
+from social.backends.oauth import BaseOAuth2, BaseOAuth1
+from social.exceptions import AuthMissingParameter, AuthCanceled
+import ipdb
+
+
+class ZoteroOAuth(BaseOAuth1):
+
+    """Zotero OAuth authorization mechanism"""
+    name = 'zotero'
+    AUTHORIZATION_URL = 'https://www.zotero.org/oauth/authorize'
+    REQUEST_TOKEN_URL = 'https://www.zotero.org/oauth/request'
+    ACCESS_TOKEN_URL = 'https://www.zotero.org/oauth/access'
+
+    def get_user_id(self, details, response):
+        """
+        Return user unique id provided by service. For Ubuntu One
+        the nickname should be original.
+        """
+        return details['userID']
+
+    def get_user_details(self, response):
+        """Return user details from Zotero API account"""
+        access_token = response.get('access_token', dict())
+        return {'username': access_token.get('username', ''),
+                'userID': access_token.get('userID', '')}

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