How to use the smartcar.const.AUTH_URL function in smartcar

To help you get started, we’ve selected a few smartcar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smartcar / python-sdk / tests / test_smartcar.py View on Github external
def test_exchange_token(self):
        body = {
            'grant_type': 'refresh_token',
            'refresh_token': 'refresh_token'
        }
        responses.add('POST', smartcar.const.AUTH_URL, json=self.expected)
        actual = self.client.exchange_refresh_token('refresh_token')
        self.assertIn('key', actual)
        self.assertTrue(actual['expiration'] > datetime.utcnow())
        self.assertTrue(actual['refresh_expiration'] > datetime.utcnow())
        self.assertEqual(request().headers['Authorization'], self.basic_auth)
        self.assertEqual(request().headers['Content-Type'], 'application/x-www-form-urlencoded')
        self.assertEqual(request().body, urlencode(body))
github smartcar / python-sdk / smartcar / smartcar.py View on Github external
def exchange_code(self, code):
        """ Exchange an authentication code for an access dictionary

        Args:
            code (str): A valid authorization code

        Returns:
            dict: dict containing the access and refresh token

        Raises:
            SmartcarException

        """
        method = 'POST'
        url = const.AUTH_URL
        data = {
            'grant_type': 'authorization_code',
            'code': code,
            'redirect_uri': self.redirect_uri,
        }
        response = requester.call(method, url, data=data, auth=self.auth).json()
        return set_expiration(response)