Firebase MismatchSenderID when Authorization key is my Server key

Really weird and no one has ever asked this.

I’m getting MismatchSenderIdas an error with my server key as my authorization key(server key).
And on the other hand, I’m getting success as a return result from my push_notification() if my device’s token as my authorization key, but no notification is received on my device.

I’m sure that my token is correct because I’m able to send to a single device with token in firebase (single device) console.

Which then leads me to this another question, but then I would like to confirm this issue before moving to the notification part

I’m pretty lost actually, since that all MismatchSenderId errors were resolved with replacing with the correct server key.

    require "dbconfig.php";

    $sql = "SELECT token FROM tokendb";
    $result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());
    $tokens = array();

    while($row = mysql_fetch_assoc($result))
        echo $row['token']; //this shows the same token compared to the token show in logcat(visual studio)
        $tokens[] = $row["token"];

      echo '<form id="form1" name="form1" method="post" action="">'.
    '<input type="text" size="100" maxlength="100" name="From" id="From" /><br>'.
    '<input type="text" size="100" maxlength="100" name="Title" id="Title" />'.
    '<input type="submit" name="Send" id="Send" value="Send" />'.


    $message = array("message" => "notification test");
    $message_status = sendFCMMessage($message, $tokens);
    echo $message_status;

    function sendFCMMessage($message,$target){

       //FCM API end-point
       $url = '';

       $fields = array();
       $fields['body'] = $message;
        $fields['registration_ids'] = $target;
        $fields['to'] = $target;

       //header with content_type api key
       $headers = array(
       //CURL request to route notification to FCM connection server (provided by Google)           
       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, $url);
       curl_setopt($ch, CURLOPT_POST, true);
       curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
       curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
       $result = curl_exec($ch);
       if ($result === FALSE) {
        die('Oops! FCM Send Error: ' . curl_error($ch));
       return $result;


EDIT: This short php code is also giving me MismatchSenderId error

$ch = curl_init("");
$header=array('Content-Type: application/json',
"Authorization: key=***(serverkey from project)");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{ \"notification\": {    \"title\": \"Test desde curl\",    \"text\": \"Otra prueba\"  },    \"to\" : \"my device's token\"}");



Uninstalling and reinstalling the app resolved the issue.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

The MismatchSenderId error is encountered when you are attempting to send to a registration token that is associated with a different Sender (Project). From the docs:

A registration token is tied to a certain group of senders. When a client app registers for FCM, it must specify which senders are allowed to send messages. You should use one of those sender IDs when sending messages to the client app. If you switch to a different sender, the existing registration tokens won’t work.

Make sure that the Server Key you are using is from the same Sender Project that the registration token is associated to. You can do this by checking your google-services.json file and see if the Sender ID there matches the Sender ID visible in the Firebase Project you are using to send the message.

For the matter of not receiving messages, It’s a bit unclear as to what is the structure of payload that your code is sending. Try checking if it is a properly structured message payload with a notification and/or data message payload.

Solution 2

Make your you are taking Server Key from Right place
Now it is little bit tricky to get Server key for Notification from firebase.

Here are the Steps :


And Take your Server Key and Sender id from their, which will work for you.

Uninstall the App and Re install it and try it.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply