转到 AWS SDK "Unable to determine service/operation name to be authorized"

Go AWS SDK "Unable to determine service/operation name to be authorized"

我正在使用 Go SDK 连接到 Kinesis Video Streams 服务。发出 GetMedia 请求时,我收到了包含以下内容的 403 响应 body:

<AccessDeniedException>
  <Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>

我正在使用 LogLevel LogDebugWithHTTPBody 来查看此信息,因为 SDK 期望 JSON 并收到 XML,导致 SerializationError

我正在使用 Go 1.9.2 并尝试对 aws-sdk-go 的 v1 和 v2 进行此操作,结果相同。

这是我的要求:

POST /getMedia HTTP/1.1
Host: kinesisvideo.us-west-2.amazonaws.com
User-Agent: aws-sdk-go/2.0.0-preview.1 (go1.9.2; darwin; amd64)
Content-Length: 141
Authorization: AWS4-HMAC-SHA256 Credential=AKIAXXXXXXXXXXXXXX/20180112/us-west-2/kinesisvideo/aws4_request, SignedHeaders=content-length;host;x-amz-date, Signature=60c625357b67c64caed32f5a0924882f26ffc776211801e94e7ecae84e7213c2
X-Amz-Date: 20180112T012511Z
Accept-Encoding: gzip

{"StartSelector":{"StartSelectorType":"NOW"},"StreamARN":"arn:aws:kinesisvideo:us-west-2:XXXXXXXXXXXXX:stream/StreamTest/XXXXXXXXXXXXX"}

回复:

HTTP/1.1 403 Forbidden
Content-Length: 130
Date: Fri, 12 Jan 2018 01:25:11 GMT
X-Amzn-Requestid: 6f1701aa-f737-11e7-bcd5-c70a68e72add

<AccessDeniedException>
  <Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>

如有任何帮助,我们将不胜感激。

为了跟进,我尝试直接发出上面的 HTTP 请求并添加 Content-Type: application/json header,现在的响应是:

{
    "Output": {
        "__type": "com.amazon.coral.service#UnknownOperationException",
        "message": null
    },
    "Version": "1.0"
}

我找到了解决办法。从文档中,

"You must first call the GetDataEndpoint API to get an endpoint to which you can then send the GetMedia requests."