在开源项目中包含 Google 地图 API 密钥吗?

发布于 2024-07-26 11:44:57 字数 205 浏览 4 评论 0原文

是否可以将您的 Google 地图 API 密钥放入源代码中并发布?

其他人可能会获取并滥用它,但我不希望每个开发人员/用户都获得自己的 API 密钥并将其输入到某个地方。 如果密钥所有者负责,我应该为该项目创建一个新的 Google 帐户吗? (该项目是 Objective-C 中的桌面应用程序和一个小型开发人员工具。)

让这变得方便的最佳方法是什么?

Is it okay to put your Google Maps API Key into your source code and publish it?

Others could take it and misuse it, but I don't want every developer / user to get their own API key and type it in somewhere. If the owner of the key is responsible, should I create a new Google account for the project? (The project is a desktop application in Objective-C and a small developer tool.)

What would be the best way to make this convenient?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

并安 2024-08-02 11:44:57

我认为这是不合法的,但即使是合法的,这在技术上也是不可能的,因为 Google 地图 API 密钥与您的域名绑定在一起。 Google 将检查 HTTP 请求的引荐来源网址以验证密钥。

无论如何,密钥并不是秘密:只需使用 Google 地图查看网站的来源即可揭示 API 密钥。

I don't think it's legal, but even it were, it's technically impossible, because the Google Maps API Key is tied to your domain name. Google will check the referrer of the HTTP request to validate the key.

The key isn't secret anyway: simply viewing the source of a website using Google Maps reveals the API key.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文