我没有找到任何有用的方法来在 java 中生成 Signature V4 以签署 AWS Chime HttpRequest。我想在我的 java 代码中使用 3 个 Aws Chime api(创建会议、创建与会者和删除会议)。
谁能帮帮我!
API 详细信息:
网址:https ://service.chime.aws.amazon.com/meetings
正文:{“ClientRequestToken”:“AXEXAMPLE”,“MediaRegion”:“us-east-2”}
标头:“content-type”、“application/json”、“host”、“service.chime.aws.amazon.com”、“x-amz-date”、“20200526T094404Z”、“authorization”、?(生成的签名)
API 密钥:JHDCHGEXAEXAMPLE 密钥:4sjfkkjffs/sfkkh/sfkj/example
private Response createMeeting() {
OkHttpClient client = new OkHttpClient();
Response response = null;
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"ClientRequestToken\": \"AXEXAMPLE\",\n \"MediaRegion\": \"us-east-2\"\n}");
Request request = new Request.Builder()
.url("https://service.chime.aws.amazon.com/meetings")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("host", "service.chime.aws.amazon.com")
.addHeader("content-length", "68")
.addHeader("x-amz-date", getIsoDate())
.addHeader("authorization", "?????????") //To be replaced by generated signature
.addHeader("cache-control", "no-cache")
.build();
try {
response = client.newCall(request).execute();
System.out.println("ResponseMessage===========> " + response.message());
} catch (IOException e) {
System.out.println("Error===========> " + e.getMessage());
}
return response;
}
我得到的错误是: 我们计算的请求签名与您提供的签名不匹配。检查您的 AWS 秘密访问密钥和签名方法。有关详细信息,请参阅服务文档。