简体   繁体   English

Firebase 函数:SignatureDoesNotMatch

[英]Firebase Functions : SignatureDoesNotMatch

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.在更换笔记本电脑并将我的 Firebase 帐户的所有权转让给另一个 3 个月的免费 Blaze 计划后,我在部署 Firebase 功能时出错。 While deploying any functions, I am getting this error.在部署任何功能时,我收到此错误。 All Firebase functions are successfully running locally.所有 Firebase 功能都在本地成功运行。

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索引.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.我曾尝试过不同的服务帐户私钥,我们可以从 firebase 项目设置中获取这些私钥,我曾尝试从不同的帐户 ex 部署功能。 owners account, other account with service admin access.所有者帐户,具有服务管理员访问权限的其他帐户。

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).请检查您的 Firebase 项目(项目设置 -> 常规 -> 您的应用程序 -> 选择您的 Android 应用程序 -> SHA 证书指纹)中的 SHA 密钥(SHA-1 和 SHA-256)是否与 Google Play 控制台(设置 - > 应用完整性 -> 应用签名 -> 应用签名密钥证书)。

Specially if you are using Google play signing to release your app.特别是如果您使用 Google Play 签名来发布您的应用程序。

try in your terminal:在您的终端中尝试:

  1. login with your firebase account firebase login:ci you will be redirected to your browser, you have to login使用您的 firebase 帐户登录 firebase login:ci您将被重定向到您的浏览器,您必须登录
  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返回终端(现在您已登录)并输入firebase projects:list以列出您可以使用登录的 firebase 帐户访问的所有项目
  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选择要将功能部署到的项目: firebase 使用注意:假定您的终端中已经安装了 npm 和 firebase-tools

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM