API 密钥如何在第 3 方应用程序中分发和使用?

How are API keys distributed and used within 3rd party apps?

我曾经使用过一个名为 mps-YouTube 的程序。它允许轻松播放 YouTube 播放列表。目前它不再工作了,因为已经达到限制(大概是因为每个 mps-YouTube 用户共享相同的 API 密钥)。

这让我很奇怪。您需要使用 google 注册一个 API 密钥,但您可以免费使用 YouTube(即使是广告拦截也没有任何问题)。

既然我必须使用 API 来通过我的浏览器观看 YouTube 视频并且没有 API 密钥,为什么 mps-YouTube 需要 API 密钥?

还有什么可以防止有人从像 mps-YouTube 这样的开源项目中获取密钥并在其他任何地方使用它?

Since I have to use the API anyway for watching YouTube videos with my browser and don't have an API key, why does mps-YouTube need an API key?

API 密钥被 Google 用来识别向其 api 发出请求的应用程序。如果来自此应用程序的请求过多,则该应用程序将被关闭或限制。

And what would prevent someone from just snatching the key from an open source project like mps-YouTube and using it anywhere else?

它违反了应用程序开发人员在创建项目时同意的 Googles TOS。与他人共享任何 google 密钥或凭据,包括将它们放入开源项目中。所以这不是问题,因为它不会/不应该发生。参见:Can I really not ship open source with Client ID?

mps-YouTube 违反服务条款

我快速搜索了该项目的源代码,发现代码中的 API 键实际上仍然存在 我已经为他们发布了一个问题 Google TOS violation 解释了为什么会这样一个坏主意。