I am getting an Error Message on App Startup Stating Logs like
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"
}
]
}
]
}
}
]
2020-04-27 12:42:34.621 22226-23596/in.co.androidapp.g7 E/Firebase-Installations: 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.
I got an email about a week earlier that I should update my google_services.json File, which I have done 4-5 times. No Improvements. It had been working fine for around a year. Its been only 2-3 days since I am facing this issue in the app.
Subsequently, Firebase Cloud Messaging and other firebase services are not working. I am not doing programmatic initialization (that is, using a FirebaseOptions object to provide these values), just the default initialization using FirebaseApp.initializeApp(this);
I have tried https://github.com/firebase/firebase-android-sdk/blob/master/firebase-installations/API_KEY_RESTRICTIONS.md
Thanks in Advance.
If you have issues with your 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.
You can test your configuration with the following CURL command. What is the error you are getting? (Note: If you are seeing JSON data the request was and your configuration is successful)
Test if your configuration works with the following CURL command:
api_key=<YOUR_API_KEY>
project_identifier=<YOUR_PROJECT_ID>
app_id=<YOUR_FIREBASE_APP_ID_EXAMPLE_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
Other relevant links regarding API keys and the Firebase Installations API: