API key Browser API keys cannot have referer restrictions when used with this API

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.

Leave a Comment