root / social / backends / skyrock.py @ a0a04c0a
History | View | Annotate | Download (1.2 kB)
1 |
"""
|
---|---|
2 |
Skyrock OAuth1 backend, docs at:
|
3 |
http://psa.matiasaguirre.net/docs/backends/skyrock.html
|
4 |
"""
|
5 |
from social.backends.oauth import BaseOAuth1 |
6 |
|
7 |
|
8 |
class SkyrockOAuth(BaseOAuth1): |
9 |
"""Skyrock OAuth authentication backend"""
|
10 |
name = 'skyrock'
|
11 |
ID_KEY = 'id_user'
|
12 |
AUTHORIZATION_URL = 'https://api.skyrock.com/v2/oauth/authenticate'
|
13 |
REQUEST_TOKEN_URL = 'https://api.skyrock.com/v2/oauth/initiate'
|
14 |
ACCESS_TOKEN_URL = 'https://api.skyrock.com/v2/oauth/token'
|
15 |
EXTRA_DATA = [('id', 'id')] |
16 |
|
17 |
def get_user_details(self, response): |
18 |
"""Return user details from Skyrock account"""
|
19 |
fullname, first_name, last_name = self.get_user_names(
|
20 |
first_name=response['firstname'],
|
21 |
last_name=response['name']
|
22 |
) |
23 |
return {'username': response['username'], |
24 |
'email': response['email'], |
25 |
'fullname': fullname,
|
26 |
'first_name': first_name,
|
27 |
'last_name': last_name}
|
28 |
|
29 |
def user_data(self, access_token): |
30 |
"""Return user data provided"""
|
31 |
return self.get_json('https://api.skyrock.com/v2/user/get.json', |
32 |
auth=self.oauth_auth(access_token))
|