firebase / firebase-admin-dotnet

Firebase Admin .NET SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
370 stars 131 forks source link

Getting SenderIdMissmatch error when trying to send notification via FCM #169

Closed bnoffer closed 4 years ago

bnoffer commented 4 years ago

Hi everyone, I working on implementing FCM on our server and I followed the Firebase Guide for FCM to setup the FirebaseApp instance. You can see the full implementation here:: https://github.com/real-digital-Mobile-Apps/net-core-push-notifications/blob/feature/RefactoringMerge/CorePush/Google/FcmSender.cs

I found a similar issue for the GO SDK: https://github.com/firebase/firebase-admin-go/issues/248 And I added the permission mentioned in the last comment, but still no luck. I am always getting the SenderIdMissmatch error from the SDK which is related to a HTTP Forbidden error from the aPI.

I also verified that the JSON that is passed as part of the constructor is correct and valid, the SDK is initialized without errors as well.

hiranya911 commented 4 years ago

It typically means your authorization credential do not match the FCM token that you're trying to send notifications to. Most likely they are from two different projects.

https://github.com/firebase/firebase-admin-dotnet/blob/c6b8bba37adb8dfa72d64c36fecd03708455d938/FirebaseAdmin/FirebaseAdmin/Messaging/MessagingErrorCode.cs#L42-L45

hiranya911 commented 4 years ago

I will close this since there's no action item I can see for the SDK implementation. If you continue to experience issues with this, please contact us via Firebase support.

bnoffer commented 4 years ago

How can that happen if everything is originating from the same Firebase project? I checked this more then twice to make sure that I have the correct configurations loaded on the server and app.

hiranya911 commented 4 years ago

@bnoffer it's hard to tell, since we have no insight to how your tokens were generated, or how they were passed to the server-side code. I'd advise you the following course of action:

  1. Log the device tokens for which this error occurs.
  2. File a support ticket and indicate your project ID and the tokens that result in the error: https://firebase.google.com/support
bnoffer commented 4 years ago

@hiranya911 Thank you very much, I will do so.

ozgurkaya111 commented 3 years ago

we have same problem , is there any solution ?

nest-don commented 1 month ago

You need to get the services JSON from the Firebase project itself. I thought wrong and got it from the Google API console after enabling Frirebase API.

The link to get the correct services JSON is here. The YOUR_PROJECT_NAME_HERE is the Google given project name.

https://console.firebase.google.com/project/YOUR_PROJECT_NAME_HERE/settings/serviceaccounts/adminsdk