SignatureDoesNotMatch 对 pre-signed URL (hellosign) 的 GET 请求

SignatureDoesNotMatch on GET request to pre-signed URL (hellosign)

我正在尝试使用 pre-signed URL 获取 e-signature 的 pdf 文件。我使用 Amplify Storage 生成 URL。然后我向 HelloSign 函数提供 URL 以将文件带入嵌入 window。我可以使用 window.open 打开文档,但这种其他方法会带来 SignatureDoesNotMatchThe request signature we calculated does not match the signature you provided. 错误。

The request signature we calculated does not match the signature you provided. Check your key and signing method.

key: string = 'bucketname/path/to/file.pdf'
expires: number = 60

const url = await Storage.get(key, {
  level: 'public',
  cacheControl: 'no-cache',
  signatureVersion: 'v4',
  ContentType: 'application/pdf',
  expires: 60,
  customPrefix: {
    public: '',
    protected: '',
    private: '',
  },
})

hellosign.open(url, {
  clientId,
  skipDomainVerification: true,
})

我在 Github 上找到的一个修复是在使用 SDK 初始化 S3 class 实例时包含 signatureVersion。但是我没有使用 SDK,所以我尝试在配置 Amplify 时提供它,如下所示:

AWSS3: {
  bucket,
  region,
  signatureVersion: 'v4',
},

不用说它没有解决问题。我在文档中找不到对此的任何引用,因为 Amplify.configure 函数在他们的文档中采用 any

我试着点击 pre-signed URL 并且能够毫无问题地下载文档。我检查了请求并看到了与来自 hellosign.open 的传出请求相匹配的正确 headers。有什么我可以尝试的想法吗?

hellosign.open() 预计只会加载嵌入的 URL。这些将 URLs return 从请求到以下端点:

  • /embedded/sign_url/(符号 URL - 嵌入式签名)
  • /template/create_embedded_draft(编辑 URL - 嵌入模板创建)
  • /embedded/edit_url/(编辑URL - 嵌入式模板编辑)
  • /unclaimed_draft/create_embedded(声明 URL 嵌入式请求)
  • /unclaimed_draft/create_embedded_with_template(声明 URL 嵌入式请求)

如果您想在您网站的 iframe 中的文档上收集签名,嵌入式签名可能就是您要寻找的。在这种情况下,您希望通过以下请求创建签名请求:

/signature_request/create_embedded

然后使用您通过 Amplify Storage 创建的 URL 作为 file_url[] 请求参数的值。

创建请求后,在响应对象中找到签名者的签名 ID,并将其用于 /embedded/sign_url/

的请求中

这将 return 一个符号 URL,您可以使用 hellosign.open().

加载它