Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions googlemaps/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def __init__(self, key=None, client_id=None, client_secret=None,
:param channel: (for Maps API for Work customers) When set, a channel
parameter with this value will be added to the requests.
This can be used for tracking purpose.
Can only be used with a Maps API client ID.
:type channel: str

:param timeout: Combined connect and read timeout for HTTP requests, in
Expand Down Expand Up @@ -390,9 +389,10 @@ def _generate_auth_url(self, path, params, accepts_clientid):
else:
params = sorted(extra_params.items()) + params[:] # Take a copy.

if self.channel:
params.append(("channel", self.channel))

if accepts_clientid and self.client_id and self.client_secret:
if self.channel:
params.append(("channel", self.channel))
params.append(("client", self.client_id))

path = "?".join([path, urlencode_params(params)])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def test_auth_url_with_channel(self):
auth_url = client._generate_auth_url(
"/test", {"param": "param"}, accepts_clientid=False
)
self.assertEqual(auth_url, "/test?param=param&key=AIzaasdf")
self.assertEqual(auth_url, "/test?param=param&channel=MyChannel_1&key=AIzaasdf")

def test_requests_version(self):
client_args_timeout = {
Expand Down