How to use the googlemaps.client.sign_hmac function in googlemaps

To help you get started, we’ve selected a few googlemaps 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 googlemaps / google-maps-services-python / test / test_client.py View on Github external
def test_hmac(self):
        """
        From http://en.wikipedia.org/wiki/Hash-based_message_authentication_code

        HMAC_SHA1("key", "The quick brown fox jumps over the lazy dog")
           = 0xde7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
        """

        message = "The quick brown fox jumps over the lazy dog"
        key = "a2V5" # "key" -> base64
        signature = "3nybhbi3iqa8ino29wqQcBydtNk="

        self.assertEqual(signature, _client.sign_hmac(key, message))
github googlemaps / google-maps-services-python / test / test_client.py View on Github external
def test_hmac(self):
        """
        From http://en.wikipedia.org/wiki/Hash-based_message_authentication_code

        HMAC_SHA1("key", "The quick brown fox jumps over the lazy dog")
           = 0xde7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
        """

        message = "The quick brown fox jumps over the lazy dog"
        key = "a2V5" # "key" -> base64
        signature = "3nybhbi3iqa8ino29wqQcBydtNk="

        self.assertEqual(signature, _client.sign_hmac(key, message))
github hzlmn / aiogmaps / tests / test_client.py View on Github external
async def test_url_signed(aresponses, enterprise_client, credentials):
    address = 'Test St.'
    params = {
        'address': address,
        'client': credentials['client_id']
    }

    path = '?'.join(['/maps/api/geocode/json',
                     urlencode_params(params.items())])
    expected_signature = sign_hmac(credentials['client_secret'], path)

    aresponses.add(
        'maps.googleapis.com',
        path + '&signature={}'.format(expected_signature),
        'get',
        aresponses.Response(
            body='{"status": "OK", "results": ["foo"]}',
            status=web.HTTPOk.status_code,
            content_type='application/json',
        ),
        match_querystring=True,
    )
    resp = await enterprise_client.geocode(address)
    assert resp == ['foo']