Reputation: 123
I am new to FCM in python.
raise AuthenticationError("There was an error authenticating the sender account")
pyfcm.errors.AuthenticationError: There was an error authenticating the sender account
While sending the push notification to the android device I am getting an error like this.
The code for the desire problem is here ==>
registration_id = "<device token>"
message_title = "title"
message_body = "test notification"
result1 = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)
print(result1)
Please guide to solve the desire problem.
Upvotes: 2
Views: 3676
Reputation: 1380
The error shows up when I use "Web API Key" from Settings > General. Instead we should be using "Server key" found in "Settings > Cloud Messaging"
push_service = FCMNotification(api_key="... Server Key - Not Web Api Key ...")
result = push_service.notify_single_device(
registration_id='recipient_fcm_token',
message_title='Hello World',
message_body='Body of the notification',
data_message={'extra': 'data'},
)
Credits to developer.clevertap.com
Upvotes: 2
Reputation: 1397
it has been fixed by removing the list from the FCM_SERVER_KEY key in setttings.py, git it as single server key it is worked now.
FCM_DJANGO_SETTINGS = {
"FCM_SERVER_KEY": "<your_server_key_in_fcm_console>"
}
It worked for me. now getting push notifications
Upvotes: 0
Reputation: 51
It seems like the API key is deprecated now. Try with this solution -> https://github.com/olucurious/PyFCM/issues/87
Upvotes: 1