Skip to content
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 #303

Closed
coyksdev opened this issue Jul 10, 2018 · 13 comments
Closed

messaging/authentication-error #303

coyksdev opened this issue Jul 10, 2018 · 13 comments
Assignees

Comments

@coyksdev
Copy link

  • Operating System version: macOS High Sierra
  • Firebase SDK version: latest
  • Library version: latest
  • Firebase Product: push notifications

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.

@google-oss-bot
Copy link

Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.

@google-oss-bot
Copy link

Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.

@hiranya911
Copy link
Contributor

Chances are some of your tokens do not belong to the same Firebase project. The API is working fine as far as I can tell.

@joseph1125
Copy link

I also has this problem, it seems like the admin.initializeApp can't load the info from credential and go to ask the info from defaultCredientals instead.

I also discovered this problem happens since 5.13.0, rolling back to 5.12.1 solves this issue

@hiranya911
Copy link
Contributor

@campanagerald Can you check this against the instructions at #302 (comment)?

@coyksdev
Copy link
Author

coyksdev commented Aug 3, 2018

hi. thanks a lot guys. ill check it later.

@hiranya911
Copy link
Contributor

This hasn't been updated in a while. I'm going to close this. Feel free to reopen/comment if the problem is encountered again.

@robertsLando
Copy link

I'm having this issue too. It only happens when using subscribeToTopic and unsubscribeFromTopic functions, send functions seems are working as I don't get any error.

@hiranya911 Any help?

@hiranya911
Copy link
Contributor

I don't have any additional info than what's shared in my earlier comments. If the problem persists I'd recommend reaching out to Firebase Support along with your project ID and token information.

@bethany-dawn
Copy link

I'm seeing this as well, but with the application default credentials. All other functions are fine.

@Sivakumar415
Copy link

I am still facing this issue any solution for this?

@shubhamgupta-work
Copy link

Go to GCP Dashboard in your project
search "API and Service"
In the "Enable APIs and Services" section, click "+Enable APIs and Services", and search "cloud messaging".
Now go to "Cloud Messaging" and "Firebase Cloud Messaging API" one by one and enable it.

@ccarlsson-logi
Copy link

ccarlsson-logi commented Jan 2, 2024

Experiencing this issue as well, even after enabling Firebase Cloud Messaging API. Also only on subscribing/unsubscribing to a topic. Any fix for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants