如何从Java调用AmazonAWSAPI?
如果我想从Java调用Amazon AWS Rest API,我有什么选择
在实现我自己的请求时,生成AWS4-HMAC-SHA256
授权头将是最困难的
基本上,这是我需要生成的标题:
Authorization: AWS4-HMAC-SHA256 Credential=AKIAJTOUYS27JPVRDUYQ/20200602/us-east-1/route53/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=ba85affa19fa4a8735ce952e50d41c8c93406a11d22b88cc98b109b529bcc15e
# 1 楼答案
但有时,您只需要进行一个简单的调用,而不想在应用程序中引入许多依赖项。你可能想实现剩下的,你自己说吧。生成正确的AWS授权头是最难实现的
下面是在没有外部依赖的纯java OpenJDK中实现这一点的代码
它实现了亚马逊AWS API签名版本4的签名过程
AmazonRequestSignatureV4Utils。爪哇
用法示例:
AmazonRequestSignatureV4Utils。爪哇
以及它将产生的痕迹:
有关此代码的最新版本,请参阅GitHub上的java-amazon-request-signature-v4存储库