【问题标题】:ApiGateway Autogenerated SDK "The request signature we calculated does not match the signature you provided" ErrorApiGateway 自动生成的 SDK “我们计算的请求签名与您提供的签名不匹配”错误
【发布时间】:2017-01-18 11:54:00
【问题描述】:

我已经尝试了所有解决方案(似乎有意义):

我浏览了一些其他不适用的帖子。

我正在使用无服务器框架来生成我的后端。它使用带有 AWS lambda 和 DynamoDB 的 API Gateway。在有 4 个其他 API 调用完美运行时,只有这一个调用给我带来了问题。

调用代码:

//code that calls it
        apiClientFactory = new ApiClientFactory();
        apiClientFactory.credentialsProvider(credentialsProvider);
        accountApiClient = apiClientFactory.build(DevsupercoolsoftwareClient.class);
...
    public static InviteCodeResponseModel createInviteCode(InviteCodeRequestModel request) {
        //request has one value, which is set to "USER"
        InviteCodeResponseModel response = accountApiClient.accountInviteCodeGet(request);
        return response;
    }

错误:

Caused by: com.amazonaws.mobileconnectors.apigateway.ApiClientException: {"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\n\nThe Canonical String for this request should have been\n'POST\n...\n"}
(Service: DevsupercoolsoftwareClient; Status Code: 403; Error Code: null; Request ID: bd8d4c91-7758-11e6-a0a0-69136ab6b7af)
  at com.amazonaws.mobileconnectors.apigateway.ApiClientHandler.handleResponse(ApiClientHandler.java:255)
  at com.amazonaws.mobileconnectors.apigateway.ApiClientHandler.invoke(ApiClientHandler.java:88)
  at java.lang.reflect.Proxy.invoke(Proxy.java:393)
  at $Proxy1.accountInviteCodeGet(Unknown Source)
  at com.camhart.supercoolsoftware.communicator.BackendCommunicator.createInviteCode(BackendCommunicator.java:62)
  at com.camhart.supercoolsoftware.activities.Devices.triggerShareMenu(Devices.java:159)
  at com.camhart.supercoolsoftware.activities.Devices.access$100(Devices.java:27)
  at com.camhart.supercoolsoftware.activities.Devices$2.doInBackground(Devices.java:134)
  at com.camhart.supercoolsoftware.activities.Devices$2.doInBackground(Devices.java:128)
  at android.os.AsyncTask$2.call(AsyncTask.java:295)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    ... 4 more

【问题讨论】:

    标签: amazon-web-services aws-lambda aws-api-gateway


    【解决方案1】:

    accountInviteCodeGet 的调用尝试使用方法主体进行HTTP GET 调用。看来这是不允许的。一旦我将其更改为 POST,一切都很好。

    我将尝试查找一些描述此行为的文档。如果可以的话,我要么编辑它,要么把它放在 cmets 中。

    编辑: 我与 AWS 支持人员进行了交谈。以下是他们向我指出的内容,即不可能在 HTTP 获取请求中包含消息正文。

    "一般来说,按照 HTTP/1.1 规范: RFC 2616,第 4.3 节明确指出: 如果请求方法的规范(第 5.1.1 节)不允许在请求中发送实体主体,则消息主体不得包含在请求中。 [+] https://www.rfc-editor.org/rfc/rfc2616#section-4.3 "

    【讨论】:

    • 您使用的是哪个版本的 API Gateway 核心?
    猜你喜欢
    • 2023-03-23
    • 1970-01-01
    • 2022-01-18
    • 2021-10-15
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多