skip to Main Content

I had an error in deploying Firebase functions after I changed my laptop and also transferred ownership of my Firebase account to another for a 3-month free Blaze plan. While deploying any functions, I am getting this error. All Firebase functions are successfully running locally.

Error code

 <Error>
    <Code>SignatureDoesNotMatch</Code>
    <Message> The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message>
<StringToSign GET 1670330017 /uploads-abc.zip</StringToSign></Error>

index.js

`

const functions = require("firebase-functions");
const admin = require("firebase-admin");
var handlebars = require("handlebars");
var fs = require("fs");
const nodemailer = require("nodemailer");


var serviceAccount = require("../service_account.json");
admin.initializeApp({
   credential: admin.credential.cert(serviceAccount),
   storageBucket: "gs://xyz.com",
   databaseURL: "https://xyz",

});


transporter = nodemailer.createTransport({
    service: "gmail",
    auth: {
      user: "username",
      pass: "password",
    },
  });

readHTMLFile = function (path, callback) {
    fs.readFile(path, { encoding: "utf-8" }, function (err, html) {
      if (err) {
        callback(err);
        throw err;
      } else {
        callback(null, html);
      }
    });
  };

exports.sendWelcomeMail = functions.https.onCall(async (data, context) => {
    // Grab the text parameter.
    const email = data.email;
    const name = data.name;
    readHTMLFile(`./welcome_page.html`, function (err, html) {
      var template = handlebars.compile(html);
      var replacements = {
        name: name,
      };
      var htmlToSend = template(replacements);
      var mailOptions = {
        from: "from-mail",
        to: email,
        subject: "Welcome to boom boom",
        html: htmlToSend,
      };
      transporter.sendMail(mailOptions, (erro, info) => {
        if (erro) {
          console.log(erro.toString());
          return erro.toString();
        }
        console.log("Sended");
  
        return "Sended";
      });
    });
  });

`

I had tried different service account private keys which we can get from firebase project settings, with that I had tried deploying functions from different account ex. owners account, other account with service admin access.

2

Answers


  1. try in your terminal :

    1. login with your firebase account firebase login:ci you will be redirected to your browser, you have to login
    2. come back to the terminal (now you are logged in) and type firebase projects:list to list all the projects that you can access with your logged in firebase account
    3. choose the project you want to deploy your function to : firebase use
      NB: you are assumed to have npm and firebase-tools already installed in your terminal
    Login or Signup to reply.
  2. Please check that SHA keys (SHA-1 and SHA-256) in your Firebase project (Project Settings -> General -> Your Apps -> Select your android app -> SHA certificate fingerprints) are same as in Google Play Console (Setup -> App integrity -> App Signings -> App Signing Key Certificate).

    Specially if you are using Google play signing to release your app.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search