Skip to content

messaging/authentication-error #302

@coyksdev

Description

@coyksdev

I followed the firebase docs on how to create an firebase admin for push notifications. this is how i set it up.

const admin = require('firebase-admin');
const serviceAccount = require('../helpers/privateKey.json');
const { fireBasePushNotification } = require('../config');

admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: fireBasePushNotification.database
});

var registrationTokens = [
'imagine this is a token'
];

var topic = 'myTopic'

admin.messaging().subscribeToTopic(registrationTokens, topic)
.then(function(response) {
// See the MessagingTopicManagementResponse reference documentation
// for the contents of response.
console.log('Successfully subscribed to topic:', response);
})
.catch(function(error) {
console.log('Error subscribing to topic:', error);
});

but when i tried to subscribe a topic it respond an error "messaging/authentication-error"
The SDK could not authenticate to the FCM servers. Make sure you authenticate the Admin SDK with a credential which has the proper permissions to send FCM messages. See Add Firebase to your app for documentation on how to authenticate the Admin SDKs.

I generated serviceAccountKey several times it doesnt work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions