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?
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!
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.
Related
I'm trying to program geocoding. I created API key, but when I add it into my website code I don't get anything, however when I don't use API everything works well. When I'm sending:
https://maps.googleapis.com/maps/api/geocode/json?address=".$adres."&key=KLUCZ_XXX
I get a response:
Browser API keys cannot have referer restrictions when used with this API.
If I use:
https://maps.googleapis.com/maps/api/geocode/json?address=".$adres"
The result is correct but the number of queries is limited per day.
Key constraint: referrals HTTP (Web) - set to the domain from which conjure inquiry. Interface Google Maps Geocoding API is turned on.
Does the API key has to be activated also somewhere else to work?
It sounds like you may be making the API call server side. I ran into this issue earlier today. Since you've placed a referrer restriction on your API key, it will be limited to executing on the browser with the web service APIs, including the Geocoding API. It didn't work for me even when manually setting the referrer in the request headers. You can find the other web service APIs on this page: https://developers.google.com/maps/web-services/
Important: If you are using any of the web service APIs with an API key that has referer restictions, your requests will fail with the error message: "API keys cannot have referer restrictions when used with this API." You should switch to using a server restriction.
You'll want to create a separate key to use server-side. You can change your restriction from a browser restriction to a server restriction by using IP addresses to restrict access, instead of browser referrers.
See this section in the Maps APIs FAQ on switching key type to a server restricted key: https://developers.google.com/maps/faq#switch-key-type
Alternatively, you can continue using a browser key and geocode client-side (JavaScript), then return the result to the backend via ajax.
If server-side geocoding is not an option, you should use the geocoder from the Google Javascript API. You can set HTTP referer restrictions on that API.
Google itself says to avoid the Non-Javascript Geocoder API for dynamic geocoding:
This service is generally designed for geocoding static
(known in advance) addresses for placement of application content on a
map; this service is not designed to respond in real time to user
input. For dynamic geocoding (for example, within a user interface
element), consult the documentation for the Maps JavaScript API client
geocoder and/or the Google Play services Location APIs.
This issue happens when you set the referrer for the server key to the domain name instead of the IP address, then it will show this message -
API keys with referer restrictions cannot be used with this API
.
For geocode API create a separate API key and restrict that API using IP address.
It worked for me.
Is it possible to get to know the amount of API-requests per referrer when sharing an API-key?
We recently reached our Quota limit. We would like to find out which of the websites using that key made the most requests.
In the dashboard for your API connection, you can see from which IP address the requests were coming. That's the only way of checking where your API Keys are used from. Google doesn't (visibly) track from which site the requests origin. If you think your keys were used from unauthorized sources, contact Google for help.
Tip: Try to use a different API key for seperate websites. That way, your API Usage is easier to track. Google says (on Best practices on using Google Maps API) this is a best practise.
On some domains Google Maps returns instead of image this error message: The Google Maps Platform server rejected your request. You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account
Domains where it does not work:
http://en.aston-martin-club.com/test_mapa.php
http://en.ktm-club.cz/test_mapa.php
Domains where it works:
http://en.renault-club.cz/test_mapa.php
http://en.lada-club.eu/test_mapa.php
The image I display on web is from http://maps.googleapis.com/maps/api/staticmap URL. It is Google Maps Stati API https://developers.google.com/maps/documentation/maps-static/intro
Why on some domains it works and some not? If it wil not work for any domain, then I think I need to add "key=YOUR_API_KEY" parameter.
I spent many hours trying to find out the reason, but did not succeeded. Any help is very welcome.
In the past (and this is probably still the case), domains that were using the API before keys became required were "grandfathered" with keyless access (they will work without a key).
Keys are now required, so regardless whether the domains "work" without keys or not, it is best to add a valid key to the request.
The things that determine whether or not the domains are "grandfathered" to keyless access are:
When the domain was created
When the domain started using the Google Maps APIs
Google rejects all the requests for static images that does not include api key in URL.
I don't know Google's threshold, but en.aston-martin-club.com is blocked by Google obviously. You must include api key in URL at least.
These 2 sites have some sample code on them. I copied and pasted the code into a php page in localhost, and they worked fine. However, the code doesn't seem to contain any API Keys. How come Google allows the code to use the Maps API without Keys? I'm obviously missing something here. What is it? Are there use cases where API Keys are not necessary? Where can I see the documentation regarding such uses cases?
http://www.codeofaninja.com/2014/06/google-maps-geocoding-example-php.html
https://gist.github.com/lazarofl/3901081#file-geocoder_example-html
The Google Maps JavaScript API v3 does not require an API key to function correctly. However, we strongly encourage you to load the Maps API using an APIs Console key which allows you to monitor your application's Maps API usage
From: https://developers.google.com/maps/signup
I m working on an application which renders google maps on an image as below
<img alt="Google Maps (Scotland)" src="http://maps.google.com/staticmap?size=480x200&maptype=mobile\&markers=55.9368450758,-3.03604939504,reda|55.9454374538,-3.18124534297,redb&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
The map is not getting rendered and when I right click on the source of image and click the url, I get the following message
"The Google Maps API server rejected your request. This site or IP is not authorized to use this API key."
I have checked the API Access on https://code.google.com/apis/console the API key seems to be all correct. Just wondering how to fix the site and IP bit?
See below the settings in google API console
Make sure you have enabled "Static Maps API" service in addition to "Google Maps API".
Make sure you have enabled the Google Maps related Services ("Google Maps Embed API" and "Static Maps API") like bellow:
And then mark them:
In the new layout you find it here:
It works for me when I enable "Google Maps Embed API" and "Static Maps API"
Make sure you have a Browser key in the Simple API Access section, and make sure the Referers is set to Any referer allowed
Activate Google Map Key here: https://console.developers.google.com/apis/api/maps_embed_backend/overview?project=[your-project]
It will enable your map instantly.
I had the same issue. I used this instead of this and that resolved the issue. Some other api parameters didn't work on the second URL either (specifically marker styles), guessing the old API is deprecated
Would also recommend using https as opposed to http. This way your users wont get cert warnings if they view the page over SSL
Not only you need to enable google static API, but also you need to include your api_key in the link.
From june 2018 you have to configure a billing account to continue using Maps static API; google "donate" 200$/day of credit
Maps Static API Usage and Billing
add key in the url is not enough
As commented by Pointy, you need to use an API key with all referrers allowed in order to use Static Maps.
You can achieve that just by removing all the referrers from the list of authorized referrers. Or just create a new API key and use it without further configuration.
More info at the Documentation