google-maps-services-python icon indicating copy to clipboard operation
google-maps-services-python copied to clipboard

Signing request with only API key

Open simoroma opened this issue 2 years ago • 2 comments

As far as I understood, using a Client ID and a secret is a legacy way to call APIs: https://developers.google.com/maps/premium/authentication/client-id/url-authorization

I would like to call the API and adding a signature using only my API key. For example doing the following: client = googlemaps.Client(key="<MY-KEY>", client_secret="<MY-SECRET>").

Nonetheless, no signature is added if I don't add a Client ID (which I do not have).

simoroma avatar Jun 30 '23 20:06 simoroma

If you would like to upvote the priority of this issue, please comment below or react with :+1: so we can see what is popular when we triage.

@simoroma Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

wangela avatar Jun 30 '23 20:06 wangela

I managed to do call the API with a key and a signature adding this:

        # Add signature
        if self.key and self.client_secret:
            params.append(("key", self.key))
            path = path + "?" + urlencode_params(params)
            print("Add signature to Google Maps API call.")
            sig = sign_hmac(self.client_secret, path)
            return path + "&signature=" + sig

here https://github.com/googlemaps/google-maps-services-python/blob/645e07de5a27c4c858b2c0673f0dd6f23ca62d28/googlemaps/client.py#L401

I can make a new pull request if someone else is interested.

simoroma avatar Jul 04 '23 07:07 simoroma