Android: Firebase Credentials

Directions on how to generate the Firebase Cloud Messaging API Credentials for sending Push Notifications to Android Mobile Apps.

📘

For Android mobile apps only - not for websites

This guide is for developers integrating OneSignal with an Android mobile app distributed via the Google Play Store.

To send push notifications to Android devices that download your app via the Google Play Store, you must use Firebase Cloud Messaging (FCM). This guide walks you through generating the required JSON private key file and configuring it in OneSignal.

A Service Account is a secure way for OneSignal to send notifications on your behalf. For more technical details, see Google’s Service Account documentation.


Requirements


Setup

1. Create or open your Firebase Project

Go to the Firebase console.

  • If you don't have a project yet, click Add project and follow the steps.
  • If you already have a project, select it and move to the next steps.
Page of Projects within Firebase

Page of Projects within Firebase

2. Make sure Firebase Cloud Messaging (FCM) API v1 is enabled

  1. In Firebase, click the gear icon next to Project Overview > Project settings.
1230

Firebase gear icon submenu, showing Project Settings

  1. Go to the Cloud Messaging tab.

If the Firebase Cloud Messaging API (V1) shows as disabled, click the 3-dot menu > Open in Cloud Console.

Cloud Messaging API (Legacy) does not need to be enabled as shown here. Only Firebase Cloud Messaging API (V1).

Firebase Cloud Messaging API (V1) is disabled in this image. Ensure it is enabled for your project.

In the Cloud Console, click Enable (you may need to wait a few minutes for the action to propagate to Firebase systems).

<https://console.developers.google.com/apis/api/fcm.googleapis.com/overview?project=>\<PROJECT_NUMBER>

Enable Firebase Cloud Messaging API v1.

3. Generate a Service Account JSON file

  1. Return to Firebase Project Settings.
  2. Go to the Service accounts tab.
  3. At the bottom, click Generate new private key.
Service accounts section within Firebase

Service Accounts section within Firebase

  1. Confirm by clicking Generate key in the popup.
Generate a FCM v1 Key within Firebase

🔒 This file contains sensitive credentials. Do not share it or check it into version control.

  1. Save the .json file in a safe location. You will need it shortly.

📘

Required Permissions

The following Service Account permissions are required for push notifications to work:

  • cloudmessaging.messages.create
  • firebase.projects.get

These should be included by default for new Firebase projects. If you're using a custom Service Account with restricted permissions, you can add these specific permissions by assigning it the following roles:

  • roles/firebasemessaging.admin (includes cloudmessaging.messages.create)
  • roles/firebase.viewer (includes firebase.projects.get)

4. Configure your OneSignal app's Android platform settings

  1. In your OneSignal dashboard, go to:
    Settings > Push & In-App > Push Platforms > Google Android (FCM)
    Click Activate.
Platforms screen within OneSignal app settings

Platforms screen within OneSignal app settings

  1. Next to the Service Account JSON, click Choose file and upload your .json file.
FCM configuration screen

FCM configuration screen

🚧

Migrating from Legacy FCM?

Select Firebase Cloud Messaging API (V1) from the dropdown.

If unsure which Firebase project to use, match the Sender ID in the legacy settings with your Firebase Project Settings > Cloud Messaging > Sender ID.

  1. Click Save and Continue.
  2. Choose your SDK and click Save & Continue.
SDK selection screen

SDK selection screen

  1. Make sure your app uses the correct OneSignal App ID in the code. Follow the Mobile SDK setup for more.
Android configuration installation and testing screen

Android configuration installation and testing screen

🚧

Check Subscribed Users

This is only for setting up FCM for the first time. If you are updating credentials or upgrading from to FCM v1, please ignore this step.

👍

Done!

Your OneSignal app is now connected to Firebase Cloud Messaging (V1). Return to Mobile SDK setup to finish setting up the Mobile SDK or return to Mobile push setup for next steps.


FAQ

Error: “This configuration is for a different Firebase Project...”

This appears when your uploaded JSON file is from a different Firebase project than your current OneSignal config (i.e. a different Sender ID). Using a different Sender ID invalidates previous push tokens.

Fix: Use the JSON file from the original Firebase project, or create a new one and contact [email protected] with your App ID for help. You should try to find the original project because uploading a different Service Account will require all your Android users to open the app again to get push notifications under these new credentials.

Can I change my Sender ID?

No. Changing your Sender ID has the same effect as using a new Service Account JSON file—it invalidates current push tokens. Once you’ve passed 100 users, OneSignal locks the Sender ID to prevent accidental token invalidation.

You should try to find the original project because uploading a different Service Account will require all your Android users to open the app again to get push notifications under these new credentials. If you need to create a new Firebase project, contact [email protected] with the App ID so we can allow this update on your app.

Does switching from Legacy API to V1 require an update?

No. If your app already includes the OneSignal SDK, switching to V1 is handled in the OneSignal dashboard—no code changes or app updates are required.

When is the deadline for FCM v1?

Google began shutting down legacy FCM APIs in July 2024. You may not have been affected immediately. We recommend making this change as soon as you can. See Google's notice for details.

Why don't I have a Sender ID on OneSignal?

If your server key starts with AIz... or looks short (around 40 characters), you’re likely using an old Google Cloud Messaging (GCM) setup. You must now create a new Firebase project and use a Service Account JSON file to continue using push.

How can I check which of my apps still use the Legacy API?

For a full list of apps, use our View apps API. Look for:

  • "gcm_key" → using Legacy, needs update
  • "fcm_v1_service_account_json" → using V1, ✅
  • Neither? App doesn’t use Android push.