Skip to content

Instantly share code, notes, and snippets.

@daneb
Created July 27, 2016 12:27
Show Gist options
  • Save daneb/18ae084f4310f78f0765f58b1ea4c48b to your computer and use it in GitHub Desktop.
Save daneb/18ae084f4310f78f0765f58b1ea4c48b to your computer and use it in GitHub Desktop.
Api Auth
@access_id = "1234"
@secret_key = ''
#@secret_key = 'helo'
body = {"hello" => "world"}.to_json
#body = 'dfqwfhadskfhasdkjlfhasdkljfhasdkljfhasklfjash'
headers = { 'Content-MD5' => Digest::MD5.base64digest(body),
'Content-Type' => "application/json",
'Date' => "#{Time.now.httpdate}",
"Authorization" => ''
}
@request = RestClient::Request.new(:url => "http://127.0.0.1:4567/about",
:headers => headers,
:method => :put,
:payload => body)
#uri = URI.parse('http://shield.staging.avengers.hetzner.co.za/v1.0/server_order')
#@request = Net::HTTP::Put.new('/about', headers)
#@request.add_field("Authorization", headers)
@signed_request = ApiAuth.sign!(@request, @access_id, @secret_key, { :override_http_method => 'PUT', :digest => 'sha256'})
result = @signed_request.execute
puts result.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment