~ubuntu-branches/debian/sid/social-auth-core/sid

« back to all changes in this revision

Viewing changes to social_core/backends/mixcloud.py

  • Committer: Package Import Robot
  • Author(s): Andre Bianchi
  • Date: 2018-02-22 19:49:12 UTC
  • Revision ID: package-import@ubuntu.com-20180222194912-4lqv8mlhnqc4ncd3
Tags: upstream-1.7.0
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
Mixcloud OAuth2 backend, docs at:
 
3
    https://python-social-auth.readthedocs.io/en/latest/backends/mixcloud.html
 
4
"""
 
5
from .oauth import BaseOAuth2
 
6
 
 
7
 
 
8
class MixcloudOAuth2(BaseOAuth2):
 
9
    name = 'mixcloud'
 
10
    ID_KEY = 'username'
 
11
    AUTHORIZATION_URL = 'https://www.mixcloud.com/oauth/authorize'
 
12
    ACCESS_TOKEN_URL = 'https://www.mixcloud.com/oauth/access_token'
 
13
    ACCESS_TOKEN_METHOD = 'POST'
 
14
 
 
15
    def get_user_details(self, response):
 
16
        fullname, first_name, last_name = self.get_user_names(response['name'])
 
17
        return {'username': response['username'],
 
18
                'email': None,
 
19
                'fullname': fullname,
 
20
                'first_name': first_name,
 
21
                'last_name': last_name}
 
22
 
 
23
    def user_data(self, access_token, *args, **kwargs):
 
24
        return self.get_json('https://api.mixcloud.com/me/',
 
25
                             params={'access_token': access_token,
 
26
                                     'alt': 'json'})