Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is api_key/current_key updated in google-services.json

It has been a while since we touch this google-services.json file. We download the file again from Firebase console and do a diff for it with whatever we have on file and saw that the api key is different 🤔.

However, we could not find any good documentation about why it is changed and what is supposed to do on our side.

      "api_key": [
        {
-         "current_key": "AI***********************************BC"
+         "current_key": "AI***********************************K0"
        }
      ],

We saw this question that this api key is supposed to be used to send push notifications. We tested notification with both versions of the key and both of them are working fine.

https://stackoverflow.com/a/38227768/1035008

What might be causing the change in the current_key field in the JSON file? Is it safe to just swap in the new file?


Edit:

We saw the old key is still there under https://console.firebase.google.com > Project Overview > Project Settings > Web API Key:

enter image description here

I guess Google just decided to move the web API key outside of file and created a new one for each project?

like image 511
Yuchen Avatar asked May 31 '26 13:05

Yuchen


1 Answers

A Firebase project can have many API keys, but each API key can only be associated with a single Firebase project. See The docs

You can view your API keys in Firebase console at APIs & Services > Credentials

From what I can gather, when you download the google-services.json it 'auto matches' what it thinks is the most appropriate key. In my case it changed the key to a different (existing) key, but both keys still work - tested with FCM Push Notifications and Firebase Analytics on Android device.

like image 97
jpmc Avatar answered Jun 02 '26 03:06

jpmc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!