Started implementing PIN for OAuth... entry doesn't show up in popup

This commit is contained in:
Anna
2010-05-20 18:03:35 -04:00
parent 4443d9d12c
commit 716e20a9b2
3 changed files with 32 additions and 10 deletions

View File

@ -7,6 +7,8 @@ import twitter_pb2
from oauthtwitter import OAuthApi
from urllib2 import HTTPError,URLError
import avcache
import webbrowser
from time import sleep
# These are the global constants for the twitter oauth entry for our app
CONSUMER_KEY = 'jGu64TPCUtyLZKyWyMJldQ'
@ -465,15 +467,29 @@ def dms_to_statuses(direct_messages):
return statuses
def get_access_token():
def get_access_token(window):
auth_api = OAuthApi(CONSUMER_KEY, CONSUMER_SECRET)
request_token = auth_api.getRequestToken()
authorization_url = auth_api.getAuthorizationURL(request_token)
# Get authentication from url... buh?
print 'debug: authorization_url: ' + authorization_url
exit(1)
webbrowser.open(authorization_url)
auth_api = OAuthApi(CONSUMER_KEY, CONSUMER_SECRET, request_token)
return auth_api.getAccessToken()
dialog = gtk.Dialog("Enter PIN", window, gtk.DIALOG_MODAL, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
entry = gtk.Entry()
dialog.vbox.pack_start(entry)
response = dialog.run()
dialog.hide()
if response == gtk.RESPONSE_OK:
pin = entry.get_text()
try:
access_token = auth_api.getAccessToken(pin)
except HTTPError:
access_token = None
return access_token
else:
return None