From 5251534283d233d5f1e9cfc33f8de9cf18cd3ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Ignacio=20S=C3=A1nchez=20Lara?= Date: Mon, 4 Jun 2018 18:07:16 +0200 Subject: [PATCH] Allow using non-Premium keys for Google Maps client --- .../cartodb_services/google/client_factory.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/google/client_factory.py b/server/lib/python/cartodb_services/cartodb_services/google/client_factory.py index feb7f4a..9593f4f 100644 --- a/server/lib/python/cartodb_services/cartodb_services/google/client_factory.py +++ b/server/lib/python/cartodb_services/cartodb_services/google/client_factory.py @@ -5,6 +5,7 @@ import googlemaps import base64 from exceptions import InvalidGoogleCredentials + class GoogleMapsClientFactory(): clients = {} @@ -13,11 +14,14 @@ class GoogleMapsClientFactory(): cache_key = "{}:{}:{}".format(client_id, client_secret, channel) client = cls.clients.get(cache_key) if not client: - cls.assert_valid_crendentials(client_secret) - client = googlemaps.Client( - client_id=client_id, - client_secret=client_secret, - channel=channel) + if client_id: + cls.assert_valid_crendentials(client_secret) + client = googlemaps.Client( + client_id=client_id, + client_secret=client_secret, + channel=channel) + else: + client = googlemaps.Client(key=client_secret) cls.clients[cache_key] = client return client