Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Commit

Permalink
encode tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon3 committed May 11, 2010
1 parent 5b46451 commit 86345e2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions twitter-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import urllib
import urllib2
import urlparse
import base64

VERSION = '2.00'
gconf_keys = {
Expand All @@ -41,8 +42,8 @@
}

consumer_tokens = {
'key': '******',
'secret': '******'
'key': 'NXlrU3psc1VIWjZkaHJhRTB5WG01UQ==',
'secret': 'RFBEbXRoVzRJQXUxcUdrSmV2VTdDc2RhS3FUdmdPN2tDMFlEY3g1OG1J',
}

twitter_urls = {
Expand Down Expand Up @@ -137,7 +138,7 @@ def post(self, message):

# build parameters to post
params = {
'oauth_consumer_key' : consumer_tokens['key'],
'oauth_consumer_key' : self.decode_token(consumer_tokens['key']),
'oauth_signature_method' : 'HMAC-SHA1',
'oauth_timestamp' : str(int(time())),
'oauth_nonce' : str(getrandbits(64)),
Expand All @@ -146,7 +147,7 @@ def post(self, message):
}
params['status'] = urllib.quote(message, '')
params['oauth_signature'] = hmac.new(
'%s&%s' % (consumer_tokens['secret'], self.access_token_secret),
'%s&%s' % (self.decode_token(consumer_tokens['secret']), self.access_token_secret),
'&'.join([
'POST',
urllib.quote(twitter_urls['post'], ''),
Expand All @@ -172,7 +173,7 @@ def setup_access_token(self):
return

params = {
'oauth_consumer_key' : consumer_tokens['key'],
'oauth_consumer_key' : self.decode_token(consumer_tokens['key']),
'oauth_signature_method' : 'HMAC-SHA1',
'oauth_timestamp' : str(int(time())),
'oauth_nonce' : str(getrandbits(64)),
Expand All @@ -182,7 +183,7 @@ def setup_access_token(self):
'x_auth_password' : gconf_client.get_string(gconf_keys['password'])
}
params['oauth_signature'] = hmac.new(
'%s&%s' % (consumer_tokens['secret'], ''),
'%s&%s' % (self.decode_token(consumer_tokens['secret']), ''),
'&'.join([
'POST',
urllib.quote(twitter_urls['access_token'], ''),
Expand All @@ -200,6 +201,9 @@ def setup_access_token(self):
gconf_client.set_string(gconf_keys['access_token_secret'], token_secret)
self.access_token = token_key
self.access_token_secret = token_secret

def decode_token(self, token):
return base64.b64decode(token)

class TwitterConfigureDialog (object):
def __init__(self, glade_file):
Expand Down

0 comments on commit 86345e2

Please sign in to comment.