Get startedEarly accessDesigned and in development. No results yet. See what's left on the roadmap.
Firebase service account and APNs key setup
Early access · launching soon.
Oricato sends every notification through your own Firebase project with Firebase Cloud Messaging (FCM HTTP v1). iPhone notifications also go through FCM, which forwards them to Apple Push Notification service (APNs). That means three things have to be in place before your first send works:
| Part | What | Needed for | Where it lives |
|---|---|---|---|
| A | A service account key with only the Firebase Cloud Messaging role | Android and iOS | Uploaded to the Oricato dashboard |
| B | An APNs authentication key (.p8) |
iOS | Uploaded to the Firebase console (not to Oricato) |
| C | A correct restriction on the Firebase Android API key | Android | Google Cloud Console |
Each part takes about five minutes. You do Part A once per app, because each Oricato project sends through exactly one Firebase project.
Prerequisites
- An Oricato project for your app. If you don’t have one yet, follow the Quickstart first. You need the admin or owner role in the project to upload or check the key.
- The Firebase project your app already uses. It’s the project named in your
google-services.json(Android) orGoogleService-Info.plist(iOS). Android and iOS builds of the same app must use the same Firebase project. - Access to that project in the Google Cloud Console with permission to create service accounts, create their keys and grant roles (for example, the Owner role, or Service Account Admin plus Service Account Key Admin plus Project IAM Admin).
- For iOS: an Apple Developer Program membership with permission to create keys (Account Holder or Admin).
- Optional: the Google Cloud CLI (
gcloud), if you prefer the command line for Part A.
Part A: Create and upload a Firebase service account key
Oricato needs a key that can send messages and nothing else. Create a dedicated service account for it.
Don’t use the default Firebase Admin SDK account. The Generate new private key button in Firebase (Project settings → Service accounts) creates a key for the
firebase-adminsdk-...account. That account can do far more than send notifications: it can read and change your databases, storage and users. Use a dedicated account with one role instead.Note: older guides point to the Firebase Admin SDK key instead. Any account name works, and a dedicated account with the single role below is the one we recommend.
Steps in the Google Cloud Console
- Open the Google Cloud Console and select the Firebase project your app uses. The Firebase project and the Google Cloud project are the same project with the same project ID.
- Go to APIs & Services → Enabled APIs & services and check that Firebase Cloud Messaging API (the HTTP v1
API,
fcm.googleapis.com) is enabled. If it isn’t, open it from the API library and click Enable. - Go to IAM & Admin → Service Accounts and click Create service account.
- Enter a name. We suggest
oricato-sender, but any name works. Click Create and continue. - Under Grant this service account access to project, add one role: Firebase Cloud Messaging API Admin
(
roles/firebasecloudmessaging.admin). Don’t add any other role. Click Continue, then Done. - Open the new service account, go to the Keys tab and choose Add key → Create new key.
- Select JSON and click Create. A
.jsonfile downloads to your computer. Google shows it only this once.
Or use the Google Cloud CLI
The same steps as commands. Replace lingora-app with your Firebase project ID.
PROJECT_ID="lingora-app"
SA_NAME="oricato-sender"
SA_EMAIL="${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com"
# Make sure the FCM HTTP v1 API is on
gcloud services enable fcm.googleapis.com --project="${PROJECT_ID}"
# Create the service account
gcloud iam service-accounts create "${SA_NAME}" \
--project="${PROJECT_ID}" \
--display-name="Oricato sender"
# Grant only the Firebase Cloud Messaging API Admin role
gcloud projects add-iam-policy-binding "${PROJECT_ID}" \
--member="serviceAccount:${SA_EMAIL}" \
--role="roles/firebasecloudmessaging.admin"
# Create a JSON key
gcloud iam service-accounts keys create "./${SA_NAME}.json" \
--iam-account="${SA_EMAIL}"
What the key file looks like
Don’t edit the file. Oricato checks these fields before it contacts Google. The values below are fake.
{
"type": "service_account",
"project_id": "lingora-app",
"private_key_id": "0000000000000000000000000000000000000000",
"private_key": "-----BEGIN PRIVATE KEY-----\nFAKE-KEY-FOR-DOCS-ONLY\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "000000000000000000000",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"universe_domain": "googleapis.com"
}
Oricato accepts the file when:
| Field | Rule |
|---|---|
type |
Exactly service_account |
project_id |
A valid Firebase project ID: 6 to 30 lowercase letters, digits or hyphens, starting with a letter and ending with a letter or digit |
private_key_id |
Present, letters and digits only |
private_key |
One unencrypted PEM RSA key (PKCS#8 or PKCS#1) of at least 2048 bits |
client_email |
A service account address that ends in .gserviceaccount.com |
client_id |
Digits only, when present |
token_uri |
https://oauth2.googleapis.com/token, absent, or the older Google token URL (rewritten to the current one) |
universe_domain |
googleapis.com or absent |
Oricato keeps only these fields. auth_uri and the certificate URLs are ignored.
Steps in the Oricato dashboard
- Open your project and go to Settings → Firebase key. (In a new project, the setup wizard shows the same uploader in its Firebase step.)
- Click Choose the .json file and pick the file you downloaded. If you can’t pick files, click Paste its contents instead, paste the whole file from the first brace to the last, and click Check and save the key.
- Wait while the dashboard shows Checking <file name> with Google… (or Checking the key with Google… when
you pasted the contents). Oricato then:
- validates the fields in the table above, before any network call;
- compares the key’s
project_idwith every key uploaded earlier for the project (including replaced ones) and, when at least half of your subscribed devices that report a Firebase project share one, with that project; - asks Google for an OAuth 2.0 access token with the
https://www.googleapis.com/auth/firebase.messagingscope; - sends FCM
validate_only(dry-run) requests to up to five of your project’s devices seen in the last seven days. Nothing is shown on those phones.
- If the dashboard asks Use a key from another Firebase project?, read the message. It names the Firebase project of the key you uploaded and the one your devices (or your current key) use. Notifications only reach phones registered with the same Firebase project. If you really are moving the app to another Firebase project, type the new project ID to confirm and click Use this key. Otherwise cancel and upload the right key.
- When the check passes, you see Connected to Firebase project followed by your project ID, and the key card shows the Firebase project, the service account email, the key ID and who uploaded it.
- Delete the
.jsonfile from your computer, and empty the trash. Never send it by email or chat. If you need a key again, create a new one.
The key is encrypted on the server that runs Oricato and never shown again. No dashboard screen or API response returns the private key, only its metadata.
Key rotation. To rotate, create a new JSON key for the same service account, click Replace key, upload it, and then delete the old key in the Google Cloud Console (Service Accounts → your account → Keys). The new key is checked with Google before it replaces the current one.
How Oricato keeps checking the key
- Check again on the key card re-runs the token request and the dry run, and shows the result in place: The key works or The key still fails with the reason.
- The key card’s status chip shows Working (
active) or Not working (invalid). - While sending, three credential failures in a row over at least two minutes mark the key
invalid. Temporary errors (timeout, unavailable, internal, quota exceeded, network) never count toward this. Asender_mismatchmarks the keyinvalidat once: this happens when a message has at least 10 results and 20% or more of them areSENDER_ID_MISMATCH, or when the first 5 results of a message’s first batch all are. Scheduling and sending then stop for the project, and System health raises a Firebase credentials stopped working (prefixed with your project name) alert. (Some System health alert texts still say Project settings → Credentials; that’s the Settings → Firebase key page.) - A key that failed with
network,oauth_failed,permission_deniedorproject_not_foundis re-checked automatically every five minutes, and goes back toactiveby itself when Google accepts it again. A key that failed withsender_mismatchorinvalid_jsonis never re-checked automatically: fix the cause, then click Check again or upload a new key.
Part B: Upload your APNs authentication key to Firebase
FCM can’t deliver to iPhones until your Firebase project has an APNs key. This key goes to Firebase, not to Oricato. Skip this part if your app has no iOS build.
What we learned in real integrations: when the APNs key is missing or invalid in Firebase, the Android build of the same app works and every iOS send fails. FCM answers
THIRD_PARTY_AUTH_ERROR, and the Oricato message report lists the failures as APNs key missing or invalid in Firebase (reasonapns_auth_error). This is never treated as a problem with your service account key, so the Firebase key card still says Working.
Steps in Apple Developer
- Sign in to Apple Developer and open Certificates, Identifiers & Profiles → Keys.
- Click the add button (+) to register a new key, and enter a name such as
Lingora APNs. - Turn on Apple Push Notifications service (APNs). If Apple asks you to configure it, choose the environment Sandbox & Production so the same key works for development builds and App Store builds.
- Click Continue, then Register.
- Click Download to save the
.p8file (for exampleAuthKey_ABC123DEFG.p8). Apple lets you download it only once. Store it in your team’s secrets manager. - Note the Key ID shown on the key page (10 characters, for example
ABC123DEFG). - Note your Team ID. It’s shown under Membership details in your Apple Developer account (10 characters, for
example
A1B2C3D4E5).
One APNs key works for all apps in your Apple Developer team, so you can reuse it in every Firebase project.
Steps in the Firebase console
- Open the Firebase console and select the same Firebase project you used in Part A.
- Go to Project settings (the gear icon) → Cloud Messaging.
- Under Apple app configuration, select your iOS app (its bundle ID, for example
com.lingora.app). - Under APNs authentication key, click Upload.
- Choose the
.p8file, enter the Key ID and Team ID, and click Upload.
Your iOS app must also have the Push Notifications capability. If you turned off Firebase method swizzling
(FirebaseAppDelegateProxyEnabled set to NO), it must also set the APNs token in Firebase Messaging itself. The
iOS quickstart covers the app side.
Part C: Check the Android API key restriction
Every google-services.json contains a Firebase API key, current_key, under client[].api_key[]. Firebase
Installations uses it to register the app, and FCM needs that registration to hand your app a token.
{
"client": [
{
"client_info": {
"android_client_info": { "package_name": "com.lingora.app" }
},
"api_key": [
{ "current_key": "AIzaSyFAKE-KEY-FOR-DOCS-ONLY-000000000" }
]
}
]
}
What we learned in real integrations: if that API key is restricted to Android apps in the Google Cloud Console, and the restriction doesn’t list your app’s package name and the SHA-1 of the certificate that signed the installed build, Firebase Installations is rejected. Logcat shows
BAD CONFIG, the FCM token stays null, and the phone can’t receive anything. In Verify setup the phone never shows up, or it shows up and the test send reports This phone hasn’t allowed notifications yet. even though notifications are allowed. A key restriction that’s missing your Play App Signing SHA-1 has the same effect for every user who installs from Google Play.
Steps
- Collect the SHA-1 fingerprint of every certificate that signs your app:
-
Debug: run the command below. Android Studio uses this keystore for debug builds.
keytool -list -v \ -keystore ~/.android/debug.keystore \ -alias androiddebugkey \ -storepass android -keypass android -
Upload key and release builds: run the same command on your release keystore with your own alias, or run
./gradlew signingReportin your project to list the SHA-1 of every build variant. -
Play App Signing: in Google Play Console, open your app → App integrity → App signing, and copy the SHA-1 of the App signing key certificate. Google Play re-signs your app with this key, so it’s the one on your users’ phones.
-
- Open the Google Cloud Console for your Firebase project and go to APIs & Services → Credentials.
- Under API keys, open the key whose value matches
current_keyin yourgoogle-services.json. Firebase usually names it Android key (auto created by Firebase). - Look at Application restrictions:
- None: nothing to do for this part.
- Android apps: make sure there’s one entry with your package name (for example
com.lingora.app) for each SHA-1 from step 1: debug, upload or release, and Play App Signing. Click Add, enter the package name and the SHA-1 (formatAA:BB:CC:..., 20 pairs), and repeat for each certificate.
- Under API restrictions, if the key is restricted to selected APIs, make sure the Firebase APIs your app uses are still in the list, including Firebase Installations API and Firebase Cloud Messaging API.
- Click Save. Changes can take up to a few minutes to apply.
- On the test phone, clear the app’s storage (or reinstall the app) so Firebase Installations registers again, then open the app.
Verify it works
- Firebase key. In Settings → Firebase key, click Check again. You should see The key works and a Working status chip.
- Verify setup. Open your project’s Verify setup checklist. The first row should read Firebase key works
with Connected to Firebase project and your project ID. (Behind the scenes, the setup status reports
credentials.stateasok.) - Android phone. Install a build with the Oricato SDK and open it. The phone should appear under Waiting for
your first phone… within a few seconds. Search logcat for
BAD CONFIG: there should be no such line from Firebase Installations. SDK messages use theOricatolog tag. - iPhone. Install a build on a real iPhone (the most reliable test for APNs), open it, and allow notifications. Click Send test notification. The test row should move to delivered (when delivery receipts are reported) and to opened after you tap the notification.
- Message report. After a real send, open the message report. There should be no APNs key missing or invalid in Firebase or Service account lacks permission rows under failures.
Troubleshooting
Upload errors
| What you see | Code | Fix |
|---|---|---|
This isn’t valid JSON. Paste the whole contents of the .json file, from { to }. |
Checked in the dashboard before upload | The pasted text isn’t complete JSON. Paste the whole file, from the first brace to the last. |
| This isn’t a Firebase service-account key. Create a JSON key for the oricato-push-sender service account (Project settings → Service accounts). | 422 credentials_rejected, reason not_service_account or invalid_json |
Both reasons show this same sentence. not_service_account: you uploaded another kind of JSON file, such as google-services.json. invalid_json: the file was edited or truncated, or a field such as private_key or client_email isn’t valid. Create a fresh JSON key for your service account (Part A, steps 6 and 7) and upload it unchanged. |
| Google rejected this key | 422 credentials_rejected, reason oauth_failed |
The key was deleted or disabled, or the service account was removed. Create a new key and upload it. |
| We couldn’t reach Google to check the key | 422 credentials_rejected, reason network |
Usually temporary. Try again in a minute. |
| Your app’s phones are registered with a different Firebase project | 422 credentials_rejected, reason wrong_firebase_project |
Every dry-run device answered SENDER_ID_MISMATCH. Upload a key from the Firebase project in your app’s google-services.json and GoogleService-Info.plist. |
| Use a key from another Firebase project? | 409 firebase_project_mismatch |
The key’s project differs from your earlier key or from your devices’ project. Type the project ID only if you’re moving the app; otherwise upload the right key. |
| Key creation is disabled in Google Cloud | Google Cloud organization policy | Your organization blocks service account keys (iam.disableServiceAccountKeyCreation). Ask your Google Cloud admin for an exception for this project. |
Key status failures (last_failure_code)
| Label on the key card | last_failure_code |
Fix | Re-checked automatically |
|---|---|---|---|
| Google refused the key | oauth_failed |
The key was deleted, disabled or expired. Create a new JSON key and click Replace key. | Every 5 minutes |
| The service account lacks permission | permission_denied |
Grant Firebase Cloud Messaging API Admin to the service account, and check that the Firebase Cloud Messaging API is enabled. Then click Check again. | Every 5 minutes |
| The Firebase project doesn’t exist | project_not_found |
The project was deleted or the key is from another project. Upload a key from the right project. | Every 5 minutes |
| Couldn’t reach Google | network |
Usually temporary. Oricato tries again by itself. | Every 5 minutes |
| The key file isn’t a valid service-account key | invalid_json |
Upload a new JSON key. | No |
| Devices belong to another Firebase project | sender_mismatch |
Sending stopped because phones are registered with another Firebase project. Fix the app’s Firebase config or upload the right key, then click Check again. No subscription was removed. | No |
The upload check proves that Google accepts the key and that it matches your devices’ Firebase project. It can’t fully prove the role, so send a test notification after any change to the service account.
Failures in a message report
| Report label | Reason | Fix |
|---|---|---|
| APNs key missing or invalid in Firebase | apns_auth_error |
Do Part B. Check that the Key ID and Team ID match the .p8 file, that the key wasn’t revoked in Apple Developer, and that it’s uploaded for the right iOS app. System health also shows an alert titled iPhone notifications are failing, named iPhone (APNs) key (both prefixed with your project name). |
| Firebase credentials rejected | unauthenticated |
Google stopped accepting the service account key. Create a new key and click Replace key. |
| Service account lacks permission | permission_denied |
Grant Firebase Cloud Messaging API Admin to the service account and enable the Firebase Cloud Messaging API. |
| Registered with another Firebase project | sender_id_mismatch |
The app’s google-services.json or GoogleService-Info.plist is from another Firebase project than the key. Use one Firebase project for the app and the key. |
| Timed out talking to Firebase | timeout |
Temporary. Oricato retries these sends. |
| Firebase rate limit reached | quota_exceeded |
Temporary. Oricato slows down and retries. |
The device never registers or never gets a token (Android)
| Symptom | Likely cause | Fix |
|---|---|---|
Logcat shows BAD CONFIG from Firebase Installations |
The Android API key restriction is missing the package name or a SHA-1 | Part C. Add the debug, upload or release, and Play App Signing SHA-1s. |
| Debug builds work, Google Play builds don’t | Play App Signing SHA-1 missing from the key restriction | Part C, step 1, Play App Signing. |
| The phone shows up in Verify setup, but the test send says This phone hasn’t allowed notifications yet. while notifications are allowed | The FCM token is null, usually because of the API key restriction | Part C, then clear the app’s storage and open it again. |
For notifications that are sent but don’t show, such as a missing messaging service in the Android manifest or OEM battery settings, see Troubleshooting delivery.
Next steps
- Quickstart: add the SDK and send your first test notification.
- iOS quickstart: Firebase Messaging, the APNs token and the Notification Service Extension.
- API keys and App Check: protect the keys your servers use to send.
- Troubleshooting delivery: fix the problems we’ve seen in real integrations.