/usr/lib/python3/dist-packages/social/backends/vimeo.py is in python3-social-auth 0.2.13-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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | from social.backends.oauth import BaseOAuth1, BaseOAuth2
class VimeoOAuth1(BaseOAuth1):
"""Vimeo OAuth authentication backend"""
name = 'vimeo'
AUTHORIZATION_URL = 'https://vimeo.com/oauth/authorize'
REQUEST_TOKEN_URL = 'https://vimeo.com/oauth/request_token'
ACCESS_TOKEN_URL = 'https://vimeo.com/oauth/access_token'
def get_user_id(self, details, response):
return response.get('person', {}).get('id')
def get_user_details(self, response):
"""Return user details from Twitter account"""
person = response.get('person', {})
fullname, first_name, last_name = self.get_user_names(
person.get('display_name', '')
)
return {'username': person.get('username', ''),
'email': '',
'fullname': fullname,
'first_name': first_name,
'last_name': last_name}
def user_data(self, access_token, *args, **kwargs):
"""Return user data provided"""
return self.get_json(
'https://vimeo.com/api/rest/v2',
params={'format': 'json', 'method': 'vimeo.people.getInfo'},
auth=self.oauth_auth(access_token)
)
class VimeoOAuth2(BaseOAuth2):
"""Vimeo OAuth2 authentication backend"""
name = 'vimeo-oauth2'
AUTHORIZATION_URL = 'https://api.vimeo.com/oauth/authorize'
ACCESS_TOKEN_URL = 'https://api.vimeo.com/oauth/access_token'
REFRESH_TOKEN_URL = 'https://api.vimeo.com/oauth/request_token'
ACCESS_TOKEN_METHOD = 'POST'
SCOPE_SEPARATOR = ','
API_ACCEPT_HEADER = {'Accept': 'application/vnd.vimeo.*+json;version=3.0'}
def get_redirect_uri(self, state=None):
"""
Build redirect with redirect_state parameter.
@Vimeo API 3 requires exact redirect uri without additional
additional state parameter included
"""
return self.redirect_uri
def get_user_id(self, details, response):
"""Return user id"""
try:
user_id = response.get('user', {})['uri'].split('/')[-1]
except KeyError:
user_id = None
return user_id
def get_user_details(self, response):
"""Return user details from account"""
user = response.get('user', {})
fullname, first_name, last_name = self.get_user_names(
user.get('name', '')
)
return {'username': fullname,
'fullname': fullname,
'first_name': first_name,
'last_name': last_name}
def user_data(self, access_token, *args, **kwargs):
"""Return user data provided"""
return self.get_json(
'https://api.vimeo.com/me',
params={'access_token': access_token},
headers=VimeoOAuth2.API_ACCEPT_HEADER,
)
|