我更新了 Firebase for Web 应用程序的 Firebase SDK。
由于更新,我的应用程序不再启动并抛出以下错误:
知道发生了什么事吗?
未被捕获(承诺)
FirebaseError:安装:创建安装请求失败,出现错误“403 PERMISSION_DENIED:对此 API firebaseinstallations.googleapis.com 方法 google.firebase.installations.v1.FirebaseInstallationsService.CreateInstallation 的请求被阻止。” (安装/请求失败)。
事实证明,新版本的 Firebase SDK 依赖于一种新的内部基础设施服务,称为 FIS(Firebase 安装服务)来定位标识符(“FID”或“实例 ID”)。
如果您对应用程序中使用的 API 密钥使用 API 密钥限制,则必须扩展这些限制,以允许使用 firebaseinstallations.googleapis.com 上的新 Firebase 安装服务。
允许您的相关 API 密钥与新的 API 密钥一起使用Firebase 安装 API https://console.cloud.google.com/apis/library/firebaseinstallations.googleapis.com:
- 去谷歌云控制台 https://console.cloud.google.com/apis/credentials?folder
- 选择相关项目(即您用于应用程序的项目)
- 打开菜单并转到
APIs & Services
-> Credentials
- click
Edit API key
对于有问题的 API 密钥
- 向下滚动到
API restrictions
- 从下拉列表中选择
Firebase Installations API
- click
Save
- 等待几分钟,让 Google 服务器更新并重试...
Note:如果您找不到Firebase 安装 API https://console.cloud.google.com/apis/library/firebaseinstallations.googleapis.com在 API 列表中,您可能首先必须enable您项目的 API(为此点击这里 https://console.cloud.google.com/apis/library/firebaseinstallations.googleapis.com).
Note:如果您不确定哪个 API 密钥在您的应用程序中使用,您可以检查每个 API 密钥的 Firebase Installations API 的使用次数 https://console.cloud.google.com/apis/api/firebaseinstallations.googleapis.com/credentials.
Note: Verify通过检查是否可以成功修复200
请求增加Firebase Installations API 请求指标页面 https://console.cloud.google.com/apis/api/firebaseinstallations.googleapis.com/metrics.
测试您的配置是否适用于以下 CURL 命令:
api_key=<YOUR_API_KEY>
project_identifier=<YOUR_PROJECT_ID>
app_id=<YOUR_FIREBASE_APP_ID_SIMILAR_TO_1:12345678:android:00000aaaaaaaa>
curl -H "content-type: application/json" -d "{appId: '$app_id', sdkVersion: 't:1'}" https://firebaseinstallations.googleapis.com/v1/projects/$project_identifier/installations/?key=$api_key
如果您的 API 密钥使用应用程序限制,您将必须使用标识您的应用程序的相应 HTTP 标头来扩展您的 CURL 请求:
- 安卓:
-H "x-android-package: com.rayo.example.app" -H "x-android-cert: 1234567890ABCDEF1234567890ABCDEFAABBCCDD"
- iOS:
-H "x-ios-bundle-identifier: com.rayo.example.app"
- Webapp:
-H "Referer: https://www.your.webapp.com/page?p=1"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)