-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
messaging/authentication-error #302
Comments
Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information. |
Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight. |
Please make sure that the tokens you generate on the frontend are created by a Firebase app instance with a For instance, if the Firebase console indicates that your project has a Sender ID of firebase.initializeApp({ messagingSenderId: '012345678912' }); By initializing the app with a proper Sender ID corresponding to your project, the generated tokens should now work with FCM registration functions used on the backend. You can find your Sender ID by following these steps:
|
Dupe of #303 |
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.
The text was updated successfully, but these errors were encountered: