/usr/lib/python3/dist-packages/social/backends/professionali.py is in python3-social-auth 1:0.2.21+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # -*- coding: utf-8 -*-
"""
Professionaly OAuth 2.0 support.
This contribution adds support for professionaly.ru OAuth 2.0.
Username is retrieved from the identity returned by server.
"""
from time import time
from social.utils import parse_qs
from social.backends.oauth import BaseOAuth2
class ProfessionaliOAuth2(BaseOAuth2):
name = 'professionali'
ID_KEY = 'user_id'
AUTHORIZATION_URL = 'https://api.professionali.ru/oauth/authorize.html'
ACCESS_TOKEN_URL = 'https://api.professionali.ru/oauth/getToken.json'
ACCESS_TOKEN_METHOD = 'POST'
EXTRA_DATA = [
('avatar_big', 'avatar_big'),
('link', 'link')
]
def get_user_details(self, response):
first_name, last_name = map(response.get, ('firstname', 'lastname'))
email = ''
if self.setting('FAKE_EMAIL'):
email = '{0}@professionali.ru'.format(time())
return {
'username': '{0}_{1}'.format(last_name, first_name),
'first_name': first_name,
'last_name': last_name,
'email': email
}
def user_data(self, access_token, response, *args, **kwargs):
url = 'https://api.professionali.ru/v6/users/get.json'
fields = list(set(['firstname', 'lastname', 'avatar_big', 'link'] +
self.setting('EXTRA_DATA', [])))
params = {
'fields': ','.join(fields),
'access_token': access_token,
'ids[]': response['user_id']
}
try:
return self.get_json(url, params)[0]
except (TypeError, KeyError, IOError, ValueError, IndexError):
return None
def get_json(self, url, *args, **kwargs):
return self.request(url, verify=False, *args, **kwargs).json()
def get_querystring(self, url, *args, **kwargs):
return parse_qs(self.request(url, verify=False, *args, **kwargs).text)
|