Firebase API 密钥(a.k.a 服务器密钥)和 Web API 密钥有什么区别?

What is the difference between Firebase API key (a.k.a Server Key) and the Web API Key?

在项目 Settings/General 下的 Firebase 控制台中,项目 ID 字段下方有一个 Web API 键:

这个用在什么地方?我知道在 Project Settings/Cloud Messaging 下找到的服务器密钥用作授权密钥来调用 firebase 控制台:

我还注意到 google-services.json 中有一个 "api_key" 属性 具有与两个键不同的 "current_key" 值我已经提到了。那把钥匙是什么?

来自我的回答

  • current key - 在使用它的文档的任何地方都没有明确说明,但是,在 Firebase 之前最初使用 google-services.json 的 3 个服务中(Google 登录、分析、GCM),我猜它会在 Google 登录和分析之间。正如@DiegoGiorgini 也提到的 here:

The api_key value in google-services.json is not used by FCM. (it is used by other Firebase libraries)

因此它可以用于单独的 Google 非 Firebase 或 Firebase 服务。

  • Web API Key - 这个我以前没机会用过。但是,我看过其他帖子,其中这个特定的 API 密钥经常用于与 Firebase 相关的 Web 应用程序(可能也用于 Auth 目的?),但我不完全确定。

  • 服务器密钥 - 根据 docs:

A server key that authorizes your app server for access to Google services, including sending messages via Firebase Cloud Messaging.

  • current_key(根据 docs)是 Firebase 在创建时自动创建的 Android 键一个 Firebase Android 应用程序。它不用于控制对后端资源的访问。相反,它用于在与 Firebase/Google 服务交互时识别您的 Firebase 项目。具体来说,它用于将 API 请求与您的配额和计费项目相关联。

  • Web API 密钥(根据docs):可用于通过将其值传递给key 多个 API 端点中的查询参数,例如,使用电子邮件和密码注册或登录、生成刷新令牌等。

  • 服务器密钥(根据docs):是授权您的应用服务器访问Google的服务器密钥服务,包括通过 Firebase Cloud Messaging 遗留协议发送消息。