FCM Topic Subscription Issue - "Authentication using server key is deprecated"

193 views
Skip to first unread message

Aadhiraj D

unread,
Sep 16, 2024, 12:49:43 PMSep 16
to Firebase Google Group

I am currently working on a project that involves subscribing a set of device tokens to specific topics using Firebase Cloud Messaging (FCM). However, during the implementation, I encountered the following error:

Error:

{"error": "Authentication using server key is deprecated. Please use an OAuth2 token instead."}

From my understanding, FCM has deprecated the use of the server key for authentication in topic subscriptions, and now it requires using an OAuth2 token. My current implementation includes a service account JSON file to fetch an OAuth2 access token. Below is the method I am using to subscribe the tokens to a topic:


$client = new Client(); $client->setAuthConfig($credentialsPath); $client->addScope('https://www.googleapis.com/auth/firebase.messaging'); $accessToken = $client->fetchAccessTokenWithAssertion()['access_token'];

Despite this, I am still receiving the error. Could you kindly advise on any changes or updates I should make to resolve this issue? I would greatly appreciate your guidance on how to properly authenticate using the OAuth2 token with FCM.

Thank you in advance for your assistance.

Reply all
Reply to author
Forward
0 new messages