Skip to content

Instantly share code, notes, and snippets.

@flukeout
Created November 20, 2009 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flukeout/239751 to your computer and use it in GitHub Desktop.
Save flukeout/239751 to your computer and use it in GitHub Desktop.
Zeep Mobile - Generating the authentication header - Python
#!/usr/bin/env python
# Created by Simon Wex (simon@zeepmobile.com) on 2008-07-12
# Copyright (c) 2008. All rights reserved.
# Released under MIT License
import base64
import hmac
import sha
import time
SECRET_ACCESS_KEY = '19c87eb3e3a28404e7ea8197d4401540'
kv = {'API_KEY': 'cef7a046258082993759bade995b3ae8',
'Body': 'The brown fox jumped over the lazy dog.',
'Version': '2008-07-18',
'SignatureVersion': '1',
'Timestamp': time.strftime('%a, %d %b %Y %H:%M:%S GMT',time.gmtime())
}
sig = hmac.new(SECRET_ACCESS_KEY, digestmod=sha)
items = kv.items()
# Sort the keys
items.sort()
for key, value in items:
sig.update(key)
sig.update(value)
print base64.encodestring(sig.digest()).strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment