Due to the Legacy Cloud Messaging API being deprecated, there were some changes made in our Java server in order to use the HTTP V1 API. The main change, since we already had the latest Firebase Admin SDK library, was for the batchImport endpoint (https://iid.googleapis.com/iid/v1:batchImport). We have been using this endpoint for exchanging APN Tokens with FCM Tokens, since many of our iOS apps are sending APN Tokens when registering for push.
In this case we were still using the Server Key and made the necessary changes in order to mint an OAuth token from the service account and use this for authorizing the request instead, which is exactly what is described here
https://iid.googleapis.com/iid/*
The endpoints will continue to work but they won’t support authentication using static server keys after 6/21/2024.
Use an OAuth 2.0 access token derived from a service account.
The issue we have faced is that the batchImport endpoint is now throwing a 401 unauthorized error, even though we have followed the migration guide. I have contacted Firebase Support and they have confirmed that the Service Account has been properly set up, the permissions are correct, the scope we are using for minting the OAuth token is the correct one ( https://www.googleapis.com/auth/firebase.messaging ), the request has the correct headers and I have confirmed that sending a push notification using the APN Token directly is successful.
The issue was first noticed when setting up a new Firebase Project, which did not allow to enable the legacy Cloud Messaging API. In addition, and in order to verify if this was the case, I disabled the legacy Cloud Messaging API in an older project and, again, I got the same 401 error while it was previously working as expected.
Is anyone else facing the same issue?
Tried to generate a completely new service account.
Tried to re-upload the APNS Authentication Key.
Expected result is for the APN Token to be successfully exchanged with an FCM Token.
The result is a 401 error while making a request to the batchImport endpoint
Thanos Besi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.