Skip to content

Instantly share code, notes, and snippets.

@mhorbul
Created September 15, 2010 23:59
Show Gist options
  • Save mhorbul/581726 to your computer and use it in GitHub Desktop.
Save mhorbul/581726 to your computer and use it in GitHub Desktop.
# Maksim Horbul
# AWS Import API test
#
# Error response all the time
#
# <ErrorResponse xmlns="http://importexport.amazonaws.com/doc/2010-06-01/">
# <Error>
# <Type>Sender</Type>
# <Code>SignatureDoesNotMatch</Code>
# <Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message>
# </Error>
# <RequestId>5e9492dc-c125-11df-ad6c-5731ef5a3d54</RequestId>
# </ErrorResponse>
#
require 'rubygems'
require 'yaml'
require 'aws/s3'
require 'net/http'
include AWS::S3
API_URL = "https://importexport.amazonaws.com/"
AWS_CONFIG = {
:access_key => FIXME,
:secret_key => FIXME
}
DEMO_MODE = true
manifest = {
:accessKeyId => AWS_CONFIG[:access_key],
:deviceId => "123456",
:manifestVersion => "2.0",
:returnAddress => {
:name => "First Last",
:street1 => "123 First St.",
:city => "San Francisco",
:stateOrProvince => "CA",
:postalCode => "10001",
:phoneNumber => "123 456 7890",
:country => "US"
},
:prefix => "/123/456",
:acl => "private"
}
expires_at = (Time.now + 3600).iso8601
signature = Authentication::QueryString.new(Net::HTTP::Get.new(API_URL),
AWS_CONFIG[:access_key],
AWS_CONFIG[:secret_key],
{ :expires => expires_at })
request = {
:Operation => :CreateJob,
:Manifest => manifest.to_yaml,
:JobType => :Import,
:SignatureVersion => 2,
:SignatureMethod => "HmacSHA1",
:ValidateOnly => DEMO_MODE
}.map { |k,v| "#{k}=#{URI.escape(v.to_s)}" }.join("&") + "&" + signature
puts "API URL: #{API_URL}"
puts "QUERY: #{request}"
puts "------"
puts `curl -i -d '#{request}' #{API_URL} 2>/dev/null`
@mhorbul
Copy link
Author

mhorbul commented Jan 31, 2011

NO, this code shows the error I got all the time until I figured out how to deal with Import/Export AWS API ( https://github.com/mhorbul/aws-ie )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment