root / social / backends / readability.py @ a0a04c0a
History | View | Annotate | Download (1.3 kB)
1 |
"""
|
---|---|
2 |
Readability OAuth1 backend, docs at:
|
3 |
http://psa.matiasaguirre.net/docs/backends/readability.html
|
4 |
"""
|
5 |
from social.backends.oauth import BaseOAuth1 |
6 |
|
7 |
|
8 |
READABILITY_API = 'https://www.readability.com/api/rest/v1'
|
9 |
|
10 |
|
11 |
class ReadabilityOAuth(BaseOAuth1): |
12 |
"""Readability OAuth authentication backend"""
|
13 |
name = 'readability'
|
14 |
ID_KEY = 'username'
|
15 |
AUTHORIZATION_URL = '{0}/oauth/authorize/'.format(READABILITY_API)
|
16 |
REQUEST_TOKEN_URL = '{0}/oauth/request_token/'.format(READABILITY_API)
|
17 |
ACCESS_TOKEN_URL = '{0}/oauth/access_token/'.format(READABILITY_API)
|
18 |
EXTRA_DATA = [('date_joined', 'date_joined'), |
19 |
('kindle_email_address', 'kindle_email_address'), |
20 |
('avatar_url', 'avatar_url'), |
21 |
('email_into_address', 'email_into_address')] |
22 |
|
23 |
def get_user_details(self, response): |
24 |
fullname, first_name, last_name = self.get_user_names(
|
25 |
first_name=response['first_name'],
|
26 |
last_name=response['last_name']
|
27 |
) |
28 |
return {'username': response['username'], |
29 |
'fullname': fullname,
|
30 |
'first_name': first_name,
|
31 |
'last_name': last_name}
|
32 |
|
33 |
def user_data(self, access_token): |
34 |
return self.get_json(READABILITY_API + '/users/_current', |
35 |
auth=self.oauth_auth(access_token))
|