2

If I use URL referrer authentication with Geocoding API it says:

There was an error while trying to fix the Venues geolocation information: API keys with referer restrictions cannot be used with this API.

Which after research I find that this means that Google Maps is looking for IP address authentication.

But if I use IP address authentication with Javascript Maps API it says:

JavaScript API error: RefererNotAllowedMapError

https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error Your site URL to be authorized: https://example.com

What can be going on?

How can I fully satisfy the good ol'Google Maps?

SirLouen
  • 137
  • 10

2 Answers2

3

It looks like you're using two different Maps APIs; the client-side JavaScript API and the server-side Geocoding API web service. This means you need 2 API keys; one restricted with HTTP referrers for client-side use, and the other one restricted by IP address for web services only.

To learn more on how API key restrictions work check out Google's documentation on API key best practices.

Hope this helps!

evan
  • 5,443
  • 2
  • 11
  • 20
  • The worst part is that this is done by a popular wordpress plugin called The Events Calendar (only one API for both services) – SirLouen Oct 16 '19 at 16:13
  • If that plugin does not support using multiple API keys then you can either (1) file a FR (2) edit the plugin's source code yourself to use multiple API keys (3) use another plugin for your map implementation. There may be other alternatives too, but in any case, I strongly advise you against leaving your single API key unrestricted and hence unsecured. – evan Oct 17 '19 at 10:28
1

I know this is 3 months old now. But I had the same problem and I found out how to solve this.

As evan said, you need 2 API Keys. And annoyingly, The Events Calendar only have one field for the API Key. BUT, I found a link here: https://support.theeventscalendar.com/ to https://support.theeventscalendar.com/716190-Using-Google-Maps-API-Key-Restrictions. The page redirects though... But I managed to screen shot parts of it before it redirects and found this snippet: https://gist.github.com/cliffordp/a2ec320313afbc1ffb5f0e5ac654b7fb (I changed the code to use a define instead because I don't want my API key in git)

This filter will make it possible to have two API KEYS.

Ann
  • 11
  • 1
  • Thanks. I already solved it with that filter some time ago, but forgot to update this thread :) As you say it's weird they don't have one field for each purpose. – SirLouen Jan 23 '20 at 14:37
  • Glad to hear you managed to solve the problem! :D I contacted Modern Tribe btw, and they fixed their redirect, so now you can find their information https://theeventscalendar.com/knowledgebase/k/using-google-maps-api-key-restrictions/ – Ann Jan 23 '20 at 16:16