Google maps api REQUEST_DENIED when using API restrictions & key

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

I have been happily using the Geocoding API from Maps for some years, with no problem. Recently I've made more keys, for different environments, and decided it would be a good idea to add API restrictions to them.

When I add these API restrictions, I suddenly start getting REQUEST_DENIED.

https://maps.googleapis.com/maps/api/geocode/json?latlng=={lt},{ln}&key={key}  This IP, site or mobile application is not authorized to use this API key, ... REQUEST_DENIED

Removing them allows the APIs to be called again.


This is the setup for the keys. We only have 2 APIs enabled, and they are both added to this key. In this configuration I can't call the Geocoding API. When I delete the restrictions the Key works again, no problem. I've not set up any other app restrictions.


回答1:

Google is now aware of the bug and it was reported in the public issue tracker:

https://issuetracker.google.com/issues/69715011

Please star the bug to add your vote and subscribe to notifications from Google. Hopefully they will fix the issue soon.

UPDATE

The bug was fixed on Google side in March 2018.



回答2:

I ran into this issue as well. I think the API Restrictions settings actually prevents the key being used for the listed APIs. In other words, it's opt-out rather than opt-in. However, that's very counterintuitive and not at all clear from the documentation.



回答3:

I too was in a similar position. I would seem like @user8960608's answer might make sense.

I applied some combinations of different restrictions but none of them seemed to make it work. Minus actually removing the any API 'restrictions' altogether.

So whilst I don't know the answer, I can only hypothesise that those restrictions do not work with Geocode at least? Perhaps that table here: https://developers.google.com/maps/faq#using-google-maps-apis might indicate that they aren't used yet, or perhaps the docs are yet to be updated.

For now we simply IP restrict the key, not perfect, but its a start.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!