Skip to content

Commit

Permalink
Use base64 library instead of .encode("base64")
Browse files Browse the repository at this point in the history
Conflicts:

	twitter/oauth.py
  • Loading branch information
sixohsix committed Mar 2, 2011
1 parent 0159136 commit 12fc192
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions twitter/oauth.py
Expand Up @@ -6,7 +6,7 @@
import urllib
import hashlib
import hmac

import base64

def write_token_file(filename, oauth_token, oauth_token_secret):
"""
Expand Down Expand Up @@ -59,8 +59,9 @@ def encode_params(self, base_url, method, params):
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]
signature = (base64.b64encode(hmac.new(
key.encode('ascii'), message.encode('ascii'), hashlib.sha1)
.digest()))
return enc_params + "&" + "oauth_signature=" + urllib.quote(signature, '')

def generate_headers(self):
Expand Down

0 comments on commit 12fc192

Please sign in to comment.