/usr/lib/python3/dist-packages/social/backends/rdio.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 | """
Rdio OAuth1 and OAuth2 backends, docs at:
http://psa.matiasaguirre.net/docs/backends/rdio.html
"""
from social.backends.oauth import BaseOAuth1, BaseOAuth2, OAuthAuth
RDIO_API = 'https://www.rdio.com/api/1/'
class BaseRdio(OAuthAuth):
ID_KEY = 'key'
def get_user_details(self, response):
fullname, first_name, last_name = self.get_user_names(
fullname=response['displayName'],
first_name=response['firstName'],
last_name=response['lastName']
)
return {
'username': response['username'],
'fullname': fullname,
'first_name': first_name,
'last_name': last_name
}
class RdioOAuth1(BaseRdio, BaseOAuth1):
"""Rdio OAuth authentication backend"""
name = 'rdio-oauth1'
REQUEST_TOKEN_URL = 'http://api.rdio.com/oauth/request_token'
AUTHORIZATION_URL = 'https://www.rdio.com/oauth/authorize'
ACCESS_TOKEN_URL = 'http://api.rdio.com/oauth/access_token'
EXTRA_DATA = [
('key', 'rdio_id'),
('icon', 'rdio_icon_url'),
('url', 'rdio_profile_url'),
('username', 'rdio_username'),
('streamRegion', 'rdio_stream_region'),
]
def user_data(self, access_token, *args, **kwargs):
"""Return user data provided"""
params = {'method': 'currentUser',
'extras': 'username,displayName,streamRegion'}
request = self.oauth_request(access_token, RDIO_API,
params, method='POST')
return self.get_json(request.url, method='POST',
data=request.to_postdata())['result']
class RdioOAuth2(BaseRdio, BaseOAuth2):
name = 'rdio-oauth2'
AUTHORIZATION_URL = 'https://www.rdio.com/oauth2/authorize'
ACCESS_TOKEN_URL = 'https://www.rdio.com/oauth2/token'
ACCESS_TOKEN_METHOD = 'POST'
EXTRA_DATA = [
('key', 'rdio_id'),
('icon', 'rdio_icon_url'),
('url', 'rdio_profile_url'),
('username', 'rdio_username'),
('streamRegion', 'rdio_stream_region'),
('refresh_token', 'refresh_token', True),
('token_type', 'token_type', True),
]
def user_data(self, access_token, *args, **kwargs):
return self.get_json(RDIO_API, method='POST', data={
'method': 'currentUser',
'extras': 'username,displayName,streamRegion',
'access_token': access_token
})['result']
|