N
Novu17mo ago
balance

Unexpected provider error

Hi, I'm currently running novu locally using docker compose. I set up a basic workflow that sends a push notification. I set up the FCM provider. I then use the following script to send a notification:
// Set device token for push
const { Novu, PushProviderIdEnum } = require('@novu/node');

const config = {
backendUrl: 'http://localhost:3000',
};

const novu = new Novu(NOVU_API_KEY, config);

// Only run once at the start
//novu.subscribers.setCredentials(SUBSCRIBER_ID, PushProviderIdEnum.FCM, {
// deviceTokens: [DEVICE_TOKEN],
//}).then((res) => { console.log("Set device token successfully."); }).catch((error) => { console.log(error); })

// Send a push notification
novu.trigger(WORKFLOW_ID, {
to: {
subscriberId: SUBSCRIBER_ID,
},
payload: {
"message": "hi"
},
});
// Set device token for push
const { Novu, PushProviderIdEnum } = require('@novu/node');

const config = {
backendUrl: 'http://localhost:3000',
};

const novu = new Novu(NOVU_API_KEY, config);

// Only run once at the start
//novu.subscribers.setCredentials(SUBSCRIBER_ID, PushProviderIdEnum.FCM, {
// deviceTokens: [DEVICE_TOKEN],
//}).then((res) => { console.log("Set device token successfully."); }).catch((error) => { console.log(error); })

// Send a push notification
novu.trigger(WORKFLOW_ID, {
to: {
subscriberId: SUBSCRIBER_ID,
},
payload: {
"message": "hi"
},
});
I downloaded the FCM toolbox app from the play store, which gives me a device token. So I can test things without having to code an app for it. If I now run my script, I see the notification in the acitvity monitor but it tells me, that there is an unexpected provider error. The details are just {}. How should I debug this? Also see https://i.imgur.com/L2TAYTu.png
Imgur
20 Replies
Novu_Bot
Novu_Bot17mo ago
@balance, you just advanced to level 3!
Pawan Jain
Pawan Jain17mo ago
Hi @balance Possible chances are it firebase configs are not matching. Service account JSON you stored in fcm integration is of same project?
balance
balanceOP17mo ago
The only place I used the service account json was in the FCM Integration. Neither the FCM Toolkit app I use to test it not my code to send notification uses it. So I can't see where anything would have to match.
Pawan Jain
Pawan Jain17mo ago
How this FCM toolkit app works? What input it takes?
balance
balanceOP17mo ago
It just gives you a device tolen but maybe I have to use their service account? https://github.com/SimonMarquis/FCM-toolbox/blob/master/app/google-services.json They use a public one or you compile it yourwelf with your own services config file, which I fidn't. I'm inexperienced with FCM.
Pawan Jain
Pawan Jain17mo ago
Yes you will have to use their service account JSON file if fcm token is generated using their fcm configs
balance
balanceOP17mo ago
So to clarify: I set up the FCM integration using the above google-services.json. I can then send a notification with the above code to the app, right?
Pawan Jain
Pawan Jain17mo ago
Yes
balance
balanceOP17mo ago
Okay, that doesn't work. How can I set the logger to be more verbose? So I get an actual error. I just don't know how to debug this if the error is {}
Pawan Jain
Pawan Jain17mo ago
@zacclifton can we increase log level while running novu in local machine?
balance
balanceOP17mo ago
ah I just saw, if I use the FCM toolbox google-service.json for the FCM integration, I get { "code": "app/invalid-credential", "message": "Service account object must contain a string \"project_id\" property." } https://docs.novu.co/channels/push/fcm#generate-service-account-key-json Is there a mismatch in configration version?
Pawan Jain
Pawan Jain17mo ago
is your json content matching this format { "type": "service_account", "project_id": "PROJECT_ID", "private_key_id": "PRIVATE_KEY_ID", "private_key": "PRIVATE_KEY", "client_email": "FIREBASE_ADMIN_SDK_EMAIL", "client_id": "CLIENT_ID", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "CLIENT_X509_CERT_URL" }
balance
balanceOP17mo ago
No, it's https://github.com/SimonMarquis/FCM-toolbox/blob/master/app/google-services.json Can't I just receive notification for testing purposes in the FCM console or something like that?
Pawan Jain
Pawan Jain17mo ago
for that also you will need fcm token generated using that that config
balance
balanceOP17mo ago
I just assume Novu adopts the file format provided by google. I do. I use the FCM Toolkit to generate a device token. The app uses the above google services file but it doesn't match novus format - for whatever reason. I'm fine using whatever - I just don't want to write a whole example application to simply receive notifications for testing purposes. There must be a simple way, can't be that uncommon o.O
Zac Clifton
Zac Clifton17mo ago
Yes, in the env file set the
LOGGING_LEVEL
LOGGING_LEVEL
env variable to verbose or debug. keep in mind not everything is logged properly at this moment.
balance
balanceOP17mo ago
thanks, I'm quit sure that my issue has to do with the mismatch between my app that receives notifications and the setup of the integration though. So how would you receive notifications for testing purposes? Do you guys have an app for that?
Pawan Jain
Pawan Jain17mo ago
Hi @balance Currently, We don't have an example app. I will ping in this thread, once it will be available
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Pawan Jain
Pawan Jain16mo ago
Hi Did you change anything from your end? is FCM service account json is of same format as in this doc https://docs.novu.co/channels/push/fcm
Want results from more Discord servers?
Add your server