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
try in your terminal :
NB: you are assumed to have npm and firebase-tools already installed in your terminal
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.