Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase: 403 PERMISSION_DENIED (FirebaseError: Installations): Requests are blocked, after updating SDKs (FirebaseInstallationsService)

Tags:

firebase

I updated the Firebase SDKs of my Firebase for Web application.
Since the update my application no longer starts and throws the following error:
Any idea what is going on?

Uncaught (in promise)
FirebaseError: Installations: Create Installation request failed with error "403 PERMISSION_DENIED: Requests to this API firebaseinstallations.googleapis.com method google.firebase.installations.v1.FirebaseInstallationsService.CreateInstallation are blocked." (installations/request-failed).

like image 439
Andreas Rayo Kniep Avatar asked Oct 22 '19 01:10

Andreas Rayo Kniep


1 Answers

It turns out that new versions of Firebase SDKs depend on a new internal infrastructure service, called FIS (the Firebase Installations Service) for targeting identifiers ("FIDs" or "Instance-IDs").
If you are using API key restrictions for the API keys you use in your application, you will have to extend those restrictions to allow usage with the new Firebase Installations Service at firebaseinstallations.googleapis.com.

To allow your API key in question to be used with the new Firebase Installations 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 & Services -> Credentials
  • click Edit API key for the API key in question
  • scroll down to API restrictions
  • from the dropdown, choose Firebase Installations API
  • click Save
  • wait a couple of minutes for Google servers to update and retry...

Note: If you cannot find the Firebase Installations API in the list of APIs, you might first have to enable the API for your project (to do so click here).

Note: If you are not sure which API key is used in your application, you can check the usage numbers of Firebase Installations API per API key.

Note: Verify your fix by checking if you can see successful 200 requests increasing on the Firebase Installations API request metrics page.


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_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;

If your API key uses App restrictions you will have to expand your CURL request with the respective HTTP headers identifying your application:

  • Android: -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"
like image 148
Andreas Rayo Kniep Avatar answered Oct 22 '22 08:10

Andreas Rayo Kniep