[Python-modules-commits] [python-social-auth] 17/131: ADDED: backend for Upwork
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:16:56 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.20
in repository python-social-auth.
commit f31ff051ff4ea7c1ff673cd0bcb987fe03db81c8
Author: Shepilov Vladislav <shepilov.v at protonmail.com>
Date: Wed Apr 20 05:50:43 2016 +0300
ADDED: backend for Upwork
Signed-off-by: Shepilov Vladislav <shepilov.v at protonmail.com>
---
social/backends/upwork.py | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/social/backends/upwork.py b/social/backends/upwork.py
new file mode 100644
index 0000000..f7dcdc2
--- /dev/null
+++ b/social/backends/upwork.py
@@ -0,0 +1,35 @@
+"""
+Upwork OAuth1 backend
+"""
+from social.backends.oauth import BaseOAuth1
+
+
+class UpworkOAuth(BaseOAuth1):
+ """Upwork OAuth authentication backend"""
+ name = 'upwork'
+ ID_KEY = 'id'
+ AUTHORIZATION_URL = 'https://www.upwork.com/services/api/auth'
+ REQUEST_TOKEN_URL = 'https://www.upwork.com/api/auth/v1/oauth/token/request'
+ REQUEST_TOKEN_METHOD = 'POST'
+ ACCESS_TOKEN_URL = 'https://www.upwork.com/api/auth/v1/oauth/token/access'
+ ACCESS_TOKEN_METHOD = 'POST'
+ REDIRECT_URI_PARAMETER_NAME = 'oauth_callback'
+
+ def get_user_details(self, response):
+ """Return user details from Upwork account"""
+ auth_user = response.get('auth_user', {})
+ first_name = auth_user.get('first_name')
+ last_name = auth_user.get('last_name')
+ fullname = '{} {}'.format(first_name, last_name)
+ return {
+ '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://www.upwork.com/api/auth/v1/info.json',
+ auth=self.oauth_auth(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