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

« back to all changes in this revision

Viewing changes to social_core/backends/moves.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
Moves OAuth2 backend, docs at:
 
3
    https://dev.moves-app.com/docs/authentication
 
4
 
 
5
Written by Avi Alkalay <avi at unix dot sh>
 
6
Certified to work with Django 1.6
 
7
"""
 
8
from .oauth import BaseOAuth2
 
9
 
 
10
 
 
11
class MovesOAuth2(BaseOAuth2):
 
12
    """Moves OAuth authentication backend"""
 
13
    name = 'moves'
 
14
    ID_KEY = 'user_id'
 
15
    AUTHORIZATION_URL = 'https://api.moves-app.com/oauth/v1/authorize'
 
16
    ACCESS_TOKEN_URL = 'https://api.moves-app.com/oauth/v1/access_token'
 
17
    ACCESS_TOKEN_METHOD = 'POST'
 
18
    EXTRA_DATA = [
 
19
        ('refresh_token', 'refresh_token', True),
 
20
        ('expires_in', 'expires'),
 
21
    ]
 
22
 
 
23
    def get_user_details(self, response):
 
24
        """Return user details Moves account"""
 
25
        return {'username': str(response.get('user_id'))}
 
26
 
 
27
    def user_data(self, access_token, *args, **kwargs):
 
28
        """Loads user data from service"""
 
29
        return self.get_json('https://api.moves-app.com/api/1.1/user/profile',
 
30
                             params={'access_token': access_token})