googlemaps / google-maps-services-python

Python client library for Google Maps API Web Services
Apache License 2.0
4.57k stars 1.31k forks source link

Signing request with only API key #494

Open simoroma opened 1 year ago

simoroma commented 1 year ago

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).

wangela commented 1 year ago

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.

simoroma commented 1 year ago

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.