Skip to content

api.aws.signature.version4

tristanls edited this page Nov 25, 2012 · 4 revisions

Generate AWS Version 4 Signature.

Since Version 0.0.0
Scope
accepts: public

Parameters

All parameters are optional, unless otherwise indicated.

awsAccessKeyId AKIAIOSFODNN7EXAMPLE required AWS Access Key Id
body My object contents... The request body (if any)
canonicalUri /foo URI-encoded version of the absolute path component of the URI (default: /)
headers { date : "Mon, 09 Sep 201... required HTTP headers for the request
httpRequestMethod POST HTTP Request Method for the request (default: GET)
queryString foo=Zoo&foo=aha required Request query string; can be empty (""), but must be provided
region us-west-1 required The AWS Region you are targeting
secretAccessKey wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY required AWS Secret Access Key
service s3 required The service you are requesting

Response fields

Response

algorithm AWS4-HMAC-SHA256 Value of the X-Amz-Algorithm header for the request
authorization AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/201... Value of the Authorization form field for the request
credential AKIAIOSFODNN7EXAMPLE/20110909/us-west-1/s3/aws4_request Value of the X-Amz-Credential header for the request
date 20110909T233600Z Value of the Date or X-Amz-Date header for the request
signature 79d33b60d4f3d7172a4f9328a52d55ef0ca636dc784694... Value of the X-Amz-Signature header for the request
signedHeaders date;host Value of the X-Amz-SignedHeaders header for the request

Error

message Missing awsAccessKeyId Error message

Example

Request

crosstalk.emit( 
  '~crosstalk.api.aws.signature.version4', 
  {
    awsAccessKeyId : "KEYNAME",
    headers : {
      date : "Mon, 09 Sep 2011 23:36:00 GMT",
      host : "host.foo.com"
    },
    queryString : "foo=Zoo&foo=aha",
    region : "us-west-1",
    service : "s3",
    secretAccessKey : "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"
  }, 
  '~crosstalk', 
  function ( error, response ) { /* ... */ } 
);

Response:

{
  "algorithm":"AWS4-HMAC-SHA256",
  "authorization":"AWS4-HMAC-SHA256 Credential=KEYNAME/20110909/us-west-1/s3/aws4_request,SignedHeaders=date;host,Signature=79d33b60d4f3d7172a4f9328a52d55ef0ca636dc78469440bc63f4d10fec5446",
  "credential":"KEYNAME/20110909/us-west-1/s3/aws4_request",
  "date":"20110909T233600Z",
  "signature":"79d33b60d4f3d7172a4f9328a52d55ef0ca636dc78469440bc63f4d10fec5446",
  "signedHeaders":"date;host"
}

Error:

{
  "message": "Missing awsAccessKeyId"
}