android – Firebase Cloud Messaging API Key-ThrowExceptions

Exception or error:

Any way to regenerate the API Key for FCM (Cloud Messaging section) in Firebase Console? The key is not editable and is different from the one automatically generated in Google APIs Console. Due to this misconfiguration I’m always getting unauthorized 401 from FCM…

How to solve:

Update: Even with the new UI of the Cloud Messaging Tab where the FCM Token is visible, the Regenerate Key button would still be visible if the Server Key was deleted.

enter image description here

Update: It seems it is now possible to regenerate the Server Key via the Firebase Console, however, the label/button (see screenshot) only shows up when there is no Server Key being used.

enter image description here

After clicking on Regenerate Key, it will generate a new Server Key which is also visible in the Google Developers Console.

Still no way to re-generate the API Key from Firebase Console. HOWEVER, I was able to re-generate it via the Developer Console.

I went through the consoles again after having a discussion with @SarthakMishra and was able to actually re-generate the API Key found in the Firebase Console.

First, I’ll provide the steps on getting to the part where to actually see the current Server Key.

  1. Select your project via the top-rightmost side.
  2. Then on left-side panel, click on the gear button and select Project Settings.
  3. Then go to the Cloud-Messaging Tab

From there, you will be able to see the Server Key and the Sender ID.

Here are the steps to re-generate the Server Key. Go to your Developer Console.

  1. On the top-rightmost side, select the project name that corresponds to your Firebase Project.
  2. On the left-side panel, click on Credentials .

After that, you will be able to see the API Keys currently available for the project. Commonly, you will see two API Keys. One Server Key and one Android Key, where it has a label beside it saying (auto created by Google Service). Click on the Server Key.

  1. Click on Regenerate Key . A prompt like this should show up:

Do you want to replace the current key with a new one?

The new key will be available immediately. The current key will be deactivated permanently in 24 hours.

  1. Click on Replace key .

After that, you will see the new Server Key generated. Go back to the page where you can see the Server Key and Sender ID and refresh it. It should match the new Server Key generated.


You dont need to regenerate the key .Follow the steps

  • Go to the firebase cosole (
  • Select your project
  • On the left hand side , click on the settings icon and select project settings
  • Then Click on the Cloud Messaging Tab
  • You will find your server key there . Use it and you should be good to go


In the FCM console go to your project, there will be a overflow menu icon showing on the project name pop up, in the Overview pane. Click on that and Manage… on the opened page showing your apps, you would be able to download the google-services.json file which contains every detail like the current api-key, plus you can navigate to the Cloud Messaging tab where it will show your Server-Key.

Leave a Reply

Your email address will not be published. Required fields are marked *