firebase - 为了使用 Firebase Cloud Messaging,我必须将哪些 API 限制列入白名单?

标签 firebase flutter firebase-cloud-messaging

我目前正在 iOS 应用程序中使用 Firebase 和 flutter 框架。

Firebase 创建的默认 Google Cloud API key 对 API 的访问不受限制,因此出于安全原因,我想将其限制为我的应用使用的某些 API。

但是,在进行 API 限制后,几乎所有 Firebase 相关组件都可以正常工作,但应用程序似乎无法获取 Firebase Cloud Messaging Token(例如 FirebaseMessaging.getToken() 调用失败)。应用程序假设检索此 token 并将其发送到后端服务器,以便服务器可以发送 FCM 消息,但当进行此调用时,它只是挂起一段时间并返回 null。

当我的应用 key 不受限制地访问 API 时,它可以正常检索 FCM token ,但一旦我限制它,它就无法检索 token 。

我目前已将以下 Firebase iOS 应用 key API 列入白名单。

  • 身份工具包 API
  • token 服务 API
  • Firebase 远程配置 API
  • Firebase 动态链接 API
  • FCM 注册 API
  • Firebase 云消息传递 API

我浏览了其他 API 列表,它们似乎与 Firebase Cloud Messaging 完全无关,所以我没有选择其他任何内容,所以我陷入了困境。其他人在尝试限制 Firebase API key 时是否遇到过此问题?

(我在下面附上了完整的 API 权限列表。)

App Engine Admin API
BigQuery API
BigQuery Storage API
Cloud Build API
Cloud Datastore API
Cloud Debugger API
Cloud Deployment Manager V2 API
Cloud DNS API
Cloud Firestore API
Cloud Functions API
Cloud Logging API
Cloud Messaging
Cloud Monitoring API
Cloud OS Login API
Cloud Pub/Sub API
Cloud Resource Manager API
Cloud Run API
Cloud Runtime Configuration API
Cloud Scheduler API
Cloud Source Repositories API
Cloud SQL
Cloud SQL Admin API
Cloud Storage
Cloud Tasks API
Cloud Testing API
Cloud Trace API
Compute Engine API
Container Registry API
FCM Registration API
Firebase App Distribution API
Firebase Cloud Messaging API
Firebase Dynamic Links API
Firebase Extensions API
Firebase Hosting API
Firebase Installations API
Firebase Management API
Firebase Mods API
Firebase Remote Config API
Firebase Rules API
Google Cloud APIs
Google Cloud Storage JSON API
Google Play Android Developer API
IAM Service Account Credentials API
Identity and Access Management (IAM) API
Identity Toolkit API
Kubernetes Engine API
Legacy Cloud Source Repositories API
Maps Embed API
Maps JavaScript API
Maps SDK for Android
Maps SDK for iOS
Maps Static API
Mobile Crash Reporting API
Service Management API
Service Usage API
Stackdriver API
Street View Publish API
Street View Static API
Token Service API

最佳答案

您还必须将 Firebase Installations API 列入白名单。

详细信息可以在这里找到:
https://github.com/firebase/firebase-android-sdk/blob/master/firebase-installations/API_KEY_RESTRICTIONS.md

关于firebase - 为了使用 Firebase Cloud Messaging,我必须将哪些 API 限制列入白名单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60807556/

相关文章:

空缓存和硬重新加载时 Firebase 托管页面未找到错误

java - 为什么我无法在 Android Studio 中使用 ImageButton 上传图像文件?

android - 如何从Flutter中的mapbox获取当前位置

android - 在库中实现 Firebase

ios - 如何使用 Firebase 创建好友列表?

firebase - 如何在 firestore 字段中插入 firebase 存储图像

flutter - 任何用于长列表的轻量级 Flutter Network Image 插件? (最多可加载 500 多个图片网址)

flutter - Getx 无法与 FutureBuilder 一起正常工作以获取更新列表

android - 使用 firebase-messaging 库时使用 firebase-core 库的 Firebase 警告

android - 从 Nativescript firebase 插件初始化 firabase.init() 时出错