I am using Firebase PhoneAuth and getting the following error.
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"
}
]
}
]
}
}
]
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
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.
If you have issues with your current API key, you can create a new API key in the Cloud Console:
APIs & Services
→ Credentials
+ CREATE CREDENTIALS
→ API key
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
config file.Usage with this service
of your API key should show a number greater than 0.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. 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.
Other relevant links regarding API keys and the Firebase Installations API :
In my case, after struggling 5 hours, finally I figured out that Firebase Installations communicate with Firebase server by wrong API key which exist in values.xml
file in this path \app\build\generated\res\google-services\debug\values
not the API key in google-services.json file.
Because, I tried to run with updated google-services.json but it doesn't help.
So you should delete this values.xml
file and it will be recreated again with the right API key automatically when you build and run.
Just delete this file and run.
If you are facing this issue in the Flutter app, then after updating the google-services.json file, you should delete the build folder from your project directory. Maybe it will work.
In my case, I have generated SHA1 key using:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
after that add this key and package name into Restrict usage to your Android apps in Google Cloud
That's it !
I am using Firebase PhoneAuth and getting the following error.
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"
}
]
}
]
}
}
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.