This file is indexed.

/usr/lib/python3/dist-packages/social/backends/untappd.py is in python3-social-auth 1:0.2.21+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
import requests

from social.backends.oauth import BaseOAuth2
from social.exceptions import AuthFailed
from social.utils import handle_http_errors


class UntappdOAuth2(BaseOAuth2):
    """Untappd OAuth2 authentication backend"""
    name = 'untappd'
    AUTHORIZATION_URL = 'https://untappd.com/oauth/authenticate/'
    ACCESS_TOKEN_URL = 'https://untappd.com/oauth/authorize/'
    BASE_API_URL = 'https://api.untappd.com'
    USER_INFO_URL = BASE_API_URL + '/v4/user/info/'
    ACCESS_TOKEN_METHOD = 'GET'
    STATE_PARAMETER = False
    REDIRECT_STATE = False
    EXTRA_DATA = [
        ('id', 'id'),
        ('bio', 'bio'),
        ('date_joined', 'date_joined'),
        ('location', 'location'),
        ('url', 'url'),
        ('user_avatar', 'user_avatar'),
        ('user_avatar_hd', 'user_avatar_hd'),
        ('user_cover_photo', 'user_cover_photo')
    ]

    def auth_params(self, state=None):
        client_id, client_secret = self.get_key_and_secret()
        params = {
            'client_id': client_id,
            'redirect_url': self.get_redirect_uri(),
            'response_type': self.RESPONSE_TYPE
        }
        return params

    def process_error(self, data):
        """
        All errors from Untappd are contained in the 'meta' key of the response.
        """
        response_code = data.get('meta', {}).get('http_code')
        if response_code is not None and response_code != requests.codes.ok:
            raise AuthFailed(self, data['meta']['error_detail'])

    @handle_http_errors
    def auth_complete(self, *args, **kwargs):
        """Completes login process, must return user instance"""
        client_id, client_secret = self.get_key_and_secret()
        code = self.data.get('code')

        self.process_error(self.data)

        # Untapped sends the access token request with URL parameters,
        # not a body
        response = self.request_access_token(
            self.access_token_url(),
            method=self.ACCESS_TOKEN_METHOD,
            params={
                'response_type': 'code',
                'code': code,
                'client_id': client_id,
                'client_secret': client_secret,
                'redirect_url': self.get_redirect_uri()
            }
        )

        self.process_error(response)

        # Both the access_token and the rest of the response are
        # buried in the 'response' key
        return self.do_auth(
            response['response']['access_token'],
            response=response['response'],
            *args, **kwargs
        )

    def get_user_details(self, response):
        """Return user details from an Untappd account"""
        # Start with the user data as it was returned
        user_data = response['user']

        # Make a few updates to match expected key names
        user_data.update({
            'username': user_data.get('user_name'),
            'email': user_data.get('settings', {}).get('email_address', ''),
            'first_name': user_data.get('first_name'),
            'last_name': user_data.get('last_name'),
            'fullname': user_data.get('first_name') + ' ' +
                        user_data.get('last_name')
        })
        return user_data

    def get_user_id(self, details, response):
        """
        Return a unique ID for the current user, by default from
        server response.
        """
        return response['user'].get(self.ID_KEY)

    def user_data(self, access_token, *args, **kwargs):
        """Loads user data from service"""
        response = self.get_json(self.USER_INFO_URL, params={
            'access_token': access_token,
            'compact': 'true'
        })
        self.process_error(response)

        # The response data is buried in the 'response' key
        return response['response']