Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
593 views
in Technique[技术] by (71.8m points)

geocoding - After months of 100% stability, today I get 403 Error on google maps services

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&amp;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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...