【问题标题】:Firebase Storage signature does not matchFirebase 存储签名不匹配
【发布时间】:2020-01-05 04:56:09
【问题描述】:

我已经阅读了很多类似的错误,但是,我找到的解决方案对我不起作用。 更改个人资料图片时遇到问题,将图片加载到 Google Chrome 时出现以下错误。 错误如下:The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method

我在服务器中使用的代码如下:

const admin = require('firebase-admin');
admin.initializeApp();


const config = {
                action: 'read',
                expires: '03-01-2030'
            };

thumbFile.getSignedUrl(config)

这是我通过服务器端获取signedUrl() 的代码。 为什么我的网址在一周左右后就失效了?

我已经阅读了以下答案,老实说,我很害怕: “Google Cloud Storage 签名 URL 的最长持续时间为 7 天。但也可以更短。永远不会更长。我猜 Firebase 存储也有同样的限制”

【问题讨论】:

    标签: javascript firebase google-cloud-storage firebase-storage


    【解决方案1】:

    我之前回答的解决方案是admin.initializeApp();必须用应用程序的serviceAccount初始化。该服务帐户是使用从项目中的 Firebase 设置中获取的服务帐户 .json 文件构建的,如下所示:

    const serviceAccount = require("./serviceAccountKey.json");
    
    admin.initializeApp({
        credential: admin.credential.cert(serviceAccount),
        storageBucket: "<YOUR APP ID>.appspot.com",
        databaseURL: "https://<YOUR APP ID>.firebaseio.com"
    });
    

    【讨论】:

    • 我也是7天后url出现SignatureDoesNotMatch的问题,是否解决了一周后getSignedUrl失效的问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-29
    • 1970-01-01
    • 1970-01-01
    • 2020-07-27
    • 2020-10-17
    • 2020-05-29
    • 1970-01-01
    相关资源
    最近更新 更多