I was just wondering if someone could shed some light on why I am seeing 403 Forbidden errors for my google maps services.
I had been loading the maps api as such:
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
And then using both the geocoding and autocomplete libraries to turn user searches into co-ordinates to display on a map on my search results.
This was working perfectly (for months) until yesterday, when I started seeing 403 Errors whenever the Autocomplete service was accessed.
I am 100% confident I wasn't reaching the 25k per day limit on queries, and I made no code changes on my side.
I have now added in an API key to my script load, and the problem dissapeared, but I want to be sure this doesn't happen again. Location based search is a main feature on our site, and if it breaks, we lose customers.
Does anyone have any insight as to why this may have happened?
And under what circumstances can it happen again?
This problem just re-emerged even with an API key set - and I think the issue actually lies with caching the google maps javascript.
I have my web server dynamically decide what javascript to combine, minify and cache locally. This is done using RequestReduce.
When the client-side javascript becomes stale (roughly 3 days in my case) - google returns 403 unauthorized.
The API key was just a red herring. I can remove the key and my code still works - as long as the maps js is "fresh".
In my case, the fix was to add maps.googleapis.com
to the RequestReduce ignore list:
javascriptUrlsToIgnore="maps.googleapis.com"
For others, just make sure to not cache the maps.googleapis.com javascript for more than a few hours, if at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With