Firebase无法与Firebase服务器通信 [英] Firebase cannot communicate with Firebase Server

查看:358
本文介绍了Firebase无法与Firebase服务器通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Firebase PhoneAuth并收到以下错误.

I am using Firebase PhoneAuth and getting the following error.

由于无效的配置,Firebase安装无法与Firebase服务器API通信.在初始化Firebase时,请更新您的Firebase初始化过程并设置有效的Firebase选项(API密钥,项目ID,应用ID).

Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.

W/Firebase-Installations: Error when communicating with the Firebase Installations server API. HTTP response: [400 Bad Request: {
  "error": {
    "code": 400,
    "message": "API key not valid. Please pass a valid API key.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console",
            "url": "https://console.developers.google.com"
          }
        ]
      }
    ]
  }
}
]

推荐答案

背景

该错误表明Google不接受您在初始化Firebase时使用的API密钥.您实际上可能使用了无效的API密钥,或者Google可能错误地将您的API密钥标识为无效.如果您的API密钥长时间未使用,则可能发生后者.

Background

The error says that the API key you use when initializing Firebase is not accepted by Google. You might in fact be using an invalid API key or Google might incorrectly identify your API key as invalid. The latter can happen if your API key has not been used in a long time.

FirebaseInstallations是Firebase服务的新基础架构,它利用您在初始化Firebase时使用的API密钥.如果您最近更新了Firebase SDK,则FirebaseInstallations可能已开始使用以前未使用过的API密钥.

FirebaseInstallations is new infrastructure for Firebase services that makes use of the API key you use when initializing Firebase. If you recently updated your Firebase SDKs, FirebaseInstallations might have started using your API key which was not used before.

如果您当前的API密钥有问题,则可以在Cloud Console中创建新的API密钥:

If you have issues with your current API key, you can create a new API key in the Cloud Console:

  • 转到 Google云控制台
  • 选择相关项目(即您用于应用程序的项目)
  • 打开菜单,然后转到APIs & ServicesCredentials
  • 在页面顶部单击+ CREATE CREDENTIALSAPI key
  • 用新创建的API密钥替换应用程序中的API密钥
  • go to the Google Cloud Console
  • choose the relevant project (i.e. the project you use for your application)
  • open the menu and go to APIs & ServicesCredentials
  • on top of the page click on + CREATE CREDENTIALSAPI key
  • replace the API key in your application with the newly created API key

如果您正在使用 Firebase控制台中的google-services.json配置文件,则首先需要删除或限制当前google-services.json中使用的API密钥,以使Firebase更新配置文件并使用新的API密钥.

In case you are using the google-services.json config file from your Firebase Console, you first have to delete or restrict the API key used in your current google-services.json in order to make Firebase update config file and use a new API key.

  • 在您的google-services.json配置文件中标识API密钥.
  • 通过对照 Firebase安装API指标页面. API密钥的Usage with this service列应显示一个大于0的数字.
  • 通过单击bin符号删除该API密钥,或者通过单击铅笔符号将Application restrictions添加到该API密钥. !!警告!不要删除应用程序的现有安装对其他Firebase服务(如Firebase Auth或Realtime-Database)所需的API密钥.
  • Identify the API key in your google-services.json config file.
  • Confirm that the API key is creating the erroneous requests by checking its usage against the Firebase Installations API metrics page. The column Usage with this service of your API key should show a number greater than 0.
  • Delete that API key by clicking the bin symbol or add Application restrictions to that API key by clicking the pencil symbol. !!Warning!! Do not delete an API key that existing installations of your applications require for other Firebase services like Firebase Auth or Realtime-Database.

请等待几分钟,以更新Google服务器.下次下载google-service.json配置文件时,应包含一个新的API密钥.

Wait a couple of minutes for Google servers to update. The next download of your google-service.json config file should contain a new API key.

有关API密钥和 Firebase安装API :

  • https://firebase.google.com/support/privacy/init-options
  • https://github.com/firebase/firebase-android-sdk/blob/master/firebase-installations/API_KEY_RESTRICTIONS.md
  • https://firebase.google.com/support/release-notes/android#2020-02-27

这篇关于Firebase无法与Firebase服务器通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆