X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/7e43e2edc96e7bf453716d651173dd6396389f42..e15fbef3f78cbc82a6c54ee8f74d40f44de249cd:/twitter/oauth.py diff --git a/twitter/oauth.py b/twitter/oauth.py index 75ac3e3..ed15492 100644 --- a/twitter/oauth.py +++ b/twitter/oauth.py @@ -9,12 +9,18 @@ import hmac def write_token_file(filename, oauth_token, oauth_token_secret): + """ + Write a token file to hold the oauth token and oauth token secret. + """ oauth_file = open(filename, 'w') print >> oauth_file, oauth_token print >> oauth_file, oauth_token_secret oauth_file.close() def read_token_file(filename): + """ + Read a token file and return the oauth token and oauth token secret. + """ f = open(filename) return f.readline().strip(), f.readline().strip() @@ -52,7 +58,7 @@ class OAuth(Auth): message = '&'.join( urllib.quote(i, '') for i in [method.upper(), base_url, enc_params]) - + signature = hmac.new( key, message, hashlib.sha1).digest().encode('base64')[:-1] return enc_params + "&" + "oauth_signature=" + urllib.quote(signature, '') @@ -68,7 +74,7 @@ def urlencode_noplus(query): if hasattr(query,"items"): # mapping objects query = query.items() - + encoded_bits = [] for n, v in query: # and do unicode here while we are at it...