【问题标题】:Safely Using a Browser Key for Google Places API Web Service on Android在 Android 上为 Google Places API Web 服务安全使用浏览器密钥
【发布时间】:2017-11-28 04:34:36
【问题描述】:

我一直在通过将PlaceAutocompleteFragment 嵌入到我的活动中来使用Google Places API for Android Autocomplete Widget。这工作正常,但由于小部件的性能和缺少完整的Google Places API Web Service 中可用的 radius 过滤器,我的实现有几个缺点。

我想开始摆脱 Android 版 Google Places API 并改用 Google Places API Web 服务 来访问更广泛的过滤选项。但是,文档说明了以下内容:

注意:Google Places API 网络服务不适用于 Android 或 iOS 受限 API 密钥。

这意味着,我假设我必须在我的应用程序中使用受浏览器或服务器限制的 API 密钥,但在 Android 上,我认为这些选项不太理想,因为可能会窃取 API 密钥。

如何在我的 Android 应用程序中安全地使用浏览器 API 密钥?

【问题讨论】:

    标签: android google-maps google-places-api google-maps-android-api-2


    【解决方案1】:

    应该从您的后端服务器调用 Web 服务。 Web 服务的 API 密钥支持 IP 地址限制。因此,为了保护您将用于 Web 服务请求的 API 密钥,您应该创建一个中间服务器,该服务器将向 Google 发送请求并将响应传回您的 Android 应用程序。要保护 API 密钥,您应该使用中间服务器的 IP 地址。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-19
      • 2013-07-16
      • 2013-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-14
      • 1970-01-01
      相关资源
      最近更新 更多