【问题标题】:SignatureDoesNotMatch on GET request to pre-signed URL (hellosign)SignatureDoesNotMatch 对预签名 URL (hellosign) 的 GET 请求
【发布时间】:2021-08-20 18:36:01
【问题描述】:

我正在尝试使用预签名 URL 获取 pdf 文件以进行电子签名。我使用 Amplify Storage 生成 URL。然后我向 HelloSign 函数提供 URL,以将文件带入嵌入窗口。我可以使用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 类实例时包含 signatureVersion。但是我没有使用 SDK,所以我尝试在配置 Amplify 时提供它:

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

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

我尝试单击预签名的 URL,并且能够毫无问题地下载文档。我检查了请求并看到了与来自hellosign.open 的传出请求相匹配的正确标头。有什么我可以尝试的想法吗?

【问题讨论】:

    标签: amazon-s3 aws-amplify hellosign-api


    【解决方案1】:

    hellosign.open() 只会加载嵌入的 URL。这些是从请求返回到以下端点的 URL:

    • /embedded/sign_url/(签名 URL - 嵌入式签名)
    • /template/create_embedded_draft(编辑 URL - 嵌入式模板创建)
    • /embedded/edit_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/ 的请求中

    这将返回一个您可以使用 hellosign.open() 加载的标志 URL。

    【讨论】:

      猜你喜欢
      • 2021-04-28
      • 1970-01-01
      • 2023-01-27
      • 1970-01-01
      • 2018-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-26
      相关资源
      最近更新 更多