我正在尝试限制 Google map API key ,以便它们只能加载到特定的 Android 应用程序上。如果我不使用任何限制,那么该 key 在应用程序中可以正常工作,因此我 100% 确定该 key 是正确的。
但是,当我在 Google 控制台中添加对 API key 的限制时, map 将停止在应用程序上加载。我遵循正确的说明来限制对特定包名称 (com.appname) 的访问,并且也使用了正确的指纹。
这是一个 PhoneGap/Cordova 应用程序,因此不是 native Android 应用程序。这就是限制不起作用的原因吗?
最佳答案
我根据@xomena 评论逐字引用了官方文档:
Before moving your app or website to production, you should secure your API key. Keys for the Maps JavaScript API use the HTTP referrers (web sites) key restriction. Learn more about keys and credentials.
To add web browser restrictions to an existing, generic API key, do the following:
- Go to the Credentials page of the Google API Console.
- Select the project that contains the API key you want to edit.
- On the Credentials page, from the list of API keys, select the name of the API key to edit the details of the key.
- In the Key restriction section of the page, select HTTP referrers (web sites), follow the on-screen instructions to set referrers, then click Save.
关于android - 如何将 Google API key 限制为 PhoneGap "Android App",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50156508/