googlemaps / google-maps-services-python

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

fix: allow calls with channels along with api key authentication #527

Open Xpshnik opened 4 months ago

Xpshnik commented 4 months ago

I would like to suggest a fix associated with channels usage in API calls.

Since client id and client secret authentication has become legacy, channels are now not unique to the calls made with this method of authentication. The usage of channels without client id is even mentioned in the following lines of code that are part of the current library version: https://github.com/googlemaps/google-maps-services-python/blob/645e07de5a27c4c858b2c0673f0dd6f23ca62d28/googlemaps/client.py#L146-L151

However, in the method __generate_authurl the channel parameter is added to the authentication URL only if client id and secret were provided. Thus it is currently impossible to apply channels to calls authenticated with just API key using this library, they are simply not part of the final authentication URL as long as client id and secret weren't provided: https://github.com/googlemaps/google-maps-services-python/blob/645e07de5a27c4c858b2c0673f0dd6f23ca62d28/googlemaps/client.py#L393-L396