Skip to content

Instantly share code, notes, and snippets.

@juggy
Created March 14, 2010 19:06
Show Gist options
  • Save juggy/332158 to your computer and use it in GitHub Desktop.
Save juggy/332158 to your computer and use it in GitHub Desktop.
API Auth
# Headers should be:
#
# X-Bol-Date: <Date of the request, format doesn't matter>
# X-Bol-Authentication: <MD5 Hash>
# Content-Type: application/xml
#
def headers
now = DateTime.now.to_s
{'X-Bol-Date'=>now, 'X-Bol-Authentication'=>auth_key(now), 'Content-Type'=>'application/xml'}
end
def auth_key(now)
auth_key_prev = 'Account:' + @account + '\n' + 'Api-Key:' + @api_key + '\n' + 'X-Bol-Date:' + now
auth_key = Digest::MD5.hexdigest(auth_key_prev)
@account + ':' + auth_key
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment