# NOT RUN {
# examples from:
# http://docs.aws.amazon.com/general/latest/gr/signature-version-2.html
true_string <- paste0("GET\n",
"elasticmapreduce.amazonaws.com\n",
"/\n",
"AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE",
"&Action=DescribeJobFlows",
"&SignatureMethod=HmacSHA256",
"&SignatureVersion=2",
"&Timestamp=2011-10-03T15\<!-- %3A19\\%3A30", -->
"&Version=2009-03-31", collapse = "")
true_sig <- "i91nKc4PWAt0JJIdXwz9HxZCJDdiy6cf/Mj6vPxyYIs="
q1 <-
list(Action = "DescribeJobFlows",
Version = "2009-03-31",
AWSAccessKeyId = "AKIAIOSFODNN7EXAMPLE",
SignatureVersion = "2",
SignatureMethod = "HmacSHA256",
Timestamp = "2011-10-03T15:19:30")
sig1 <-
signature_v2_auth(datetime = "2011-10-03T15:19:30",
service = "elasticmapreduce.amazonaws.com",
verb = "GET",
path = "/",
query_args = q1,
key = q1$AWSAccessKeyId,
secret = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY")
identical(true_string, sig1$CanonicalRequest)
identical(true_sig, sig1$Signature)
# leaving out some defaults
q2 <-
list(Action = "DescribeJobFlows",
Version = "2009-03-31",
Timestamp = "2011-10-03T15:19:30")
sig2 <-
signature_v2_auth(datetime = "2011-10-03T15:19:30",
service = "elasticmapreduce.amazonaws.com",
verb = "GET",
path = "/",
query_args = q2,
key = "AKIAIOSFODNN7EXAMPLE",
secret = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY")
identical(true_string, sig2$CanonicalRequest)
identical(true_sig, sig2$Signature)
# }
Run the code above in your browser using DataLab