Created
March 14, 2010 19:06
-
-
Save juggy/332158 to your computer and use it in GitHub Desktop.
API Auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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