Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The geolocation module supports using two different Google Maps API keys, one for front-end functionality, and one for back-end.
This allows users to whitelist API keys based on HTTP referrer (for the front-end), and by IP address (for the back-end).
However, there's a bug that prevents server API requests from being whitelisted by IP address. It happens in GoogleGeocodingAPI.php in the geocode() method. The method properly checks if there is a server key, but it does not use the server key.
if (!empty($this->geolocationSettings->get('google_map_api_server_key'))) {
$request_url .= '&key=' . $this->geolocationSettings->get('google_map_api_key'); // This is incorrect.
}
elseif (!empty($this->geolocationSettings->get('google_map_api_key'))) {
$request_url .= '&key=' . $this->geolocationSettings->get('google_map_api_key');
}
Will attach patch shortly.
Comment | File | Size | Author |
---|---|---|---|
#2 | geolocation-2950947-2-google-map-server-api-key-fix.patch | 1.27 KB | donutdan4114 |
|
Comments
Comment #2
donutdan4114 CreditAttribution: donutdan4114 at Bonify commentedPatch fixes the issue and include additional error reporting for when requests fail so you can easily see which IP address or referrer you need to whitelist.
Comment #3
donutdan4114 CreditAttribution: donutdan4114 at Bonify commentedComment #6
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedThanks!
Comment #8
jkeasley CreditAttribution: jkeasley commentedAs a result of the changes to Google maps that went into action on 16 july a google maps api key is required in all cases.
This fix needs to be rolled into the production branch, as the backend interface is currently broken leaving user's unable to edit map information
Comment #9
imclean CreditAttribution: imclean commentedWe're using both backend and frontend keys, which doesn't work out of the box. See related issue: #2981953: Confusion over server and client API keys