Hello Guy Wouters,
The Push Notification System rejected the request because of an invalid credential
Try the Below Workaround to resolve this issue:
Confirm Token Handling by Azure Notification Hub
Azure internally handles OAuth2 token refresh for FCM V1 service accounts.
FCM V1 tokens expire after 1 hour. Intermittent failures may occur if token refresh fails due to caching or transient network issues.
For more details, please refer the following documentation: Firebase OAuth 2.0 Tokens,
Force Reauthentication with Fresh Credentials
To avoid cached/stale credentials:
Delete existing FCM V1 credentials in the Azure Portal.
Regenerate a new service account key in the Firebase Console.
Re-add the new JSON key into the Azure Notification Hub under FCM V1 Settings.
Refer: Configure FCM V1 in Azure
Validate Network Connectivity (Advanced)
Use tools like Azure Network Watcher, tcping
, or similar from your environment to test outbound HTTPS access:
tcping fcm.googleapis.com 443
Even brief interruptions to fcm.googleapis.com:443
can trigger token refresh or auth issues.
Enable Logging at Namespace Level
Azure logs for Notification Hub are only available at the namespace level (NHNS).
- Navigate to Notification Hub Namespace > Diagnostic settings.
- Enable logs:
OperationalLogs
,RuntimeAuditLogs
, Send to Log Analytics or Storage Account - Use this Kusto query in Log Analytics:
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.NOTIFICATIONHUBS"
| where OperationName == "Microsoft.NotificationHubs/namespaces/notificationHubs/messages/send"
| project TimeGenerated, ResultDescription, CorrelationId
| order by TimeGenerated desc
Note: Logs may take 5–10 minutes to appear after enabling diagnostics.
Refer: Enable NH Diagnostic Logs
Validate Service Account Configuration in Google Cloud
- Go to IAM & Admin > Service Accounts.
- Select your service account used for FCM V1.
Ensure the service account has the Firebase Admin or Editor role.
Refer: Managing Service Account Keys
Verify Direct Communication with FCM
You can run a test script to simulate sending messages directly to FCM. This helps isolate whether the issue is with Azure or the Firebase configuration.
Example Bash script (using gcloud
CLI):
while true; do
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-d '{
"message":{
"token":"DEVICE_TOKEN",
"notification":{
"title":"Test",
"body":"Direct FCM Test"
}
}
}' \
"https://fcm.googleapis.com/v1/projects/YOUR_PROJECT_ID/messages:send"
sleep 300
done
If this script also fails intermittently, the issue is likely on the Firebase side.
You mentioned that your Firebase project works better when not testing via the Azure Portal. This aligns with known limitations of Test Send in the Portal.
Note: Use a C# client or direct REST API to register devices and send notifications. This provides more visibility and reliability.
I hope this information helps.
Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.