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

« back to all changes in this revision

Viewing changes to social_core/backends/orbi.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
Orbi OAuth2 backend
 
3
"""
 
4
from .oauth import BaseOAuth2
 
5
 
 
6
 
 
7
class OrbiOAuth2(BaseOAuth2):
 
8
    """Orbi OAuth2 authentication backend"""
 
9
    name = 'orbi'
 
10
    AUTHORIZATION_URL = 'https://login.orbi.kr/oauth/authorize'
 
11
    ACCESS_TOKEN_URL = 'https://login.orbi.kr/oauth/token'
 
12
    ACCESS_TOKEN_METHOD = 'POST'
 
13
    EXTRA_DATA = [
 
14
        ('imin', 'imin'),
 
15
        ('nick', 'nick'),
 
16
        ('photo', 'photo'),
 
17
        ('sex', 'sex'),
 
18
        ('birth', 'birth'),
 
19
    ]
 
20
 
 
21
    def get_user_id(self, details, response):
 
22
        return response.get('id')
 
23
 
 
24
    def get_user_details(self, response):
 
25
        fullname, first_name, last_name = self.get_user_names(
 
26
            response.get('name', ''),
 
27
            response.get('first_name', ''),
 
28
            response.get('last_name', '')
 
29
        )
 
30
        return {
 
31
            'username': response.get('username', response.get('name')),
 
32
            'email': response.get('email', ''),
 
33
            'fullname': fullname,
 
34
            'first_name': first_name,
 
35
            'last_name': last_name,
 
36
        }
 
37
 
 
38
    def user_data(self, access_token, *args, **kwargs):
 
39
        """Load user data from orbi"""
 
40
        return self.get_json('https://login.orbi.kr/oauth/user/get', params={
 
41
            'access_token': access_token
 
42
        })