Sketched out a basic method for oauth to work in my app...

This commit is contained in:
Anna
2010-05-20 16:51:51 -04:00
parent e32209bf2b
commit f70e76acc2
3 changed files with 40 additions and 13 deletions

View File

@ -9,8 +9,8 @@ from urllib2 import HTTPError,URLError
import avcache
# These are the global constants for the twitter oauth entry for our app
CONSUMER_KEY = jGu64TPCUtyLZKyWyMJldQ
CONSUMER_SECRET = lTRrTyvzRfJab5HsAe16zkV8tqFVRp0k0cTfHL0l4GE
CONSUMER_KEY = 'jGu64TPCUtyLZKyWyMJldQ'
CONSUMER_SECRET = 'lTRrTyvzRfJab5HsAe16zkV8tqFVRp0k0cTfHL0l4GE'
class CustomApi(OAuthApi):
@ -20,11 +20,13 @@ class CustomApi(OAuthApi):
instantiated
'''
def __init__(self, access_token):
def __init__(self, username, access_token):
OAuthApi.__init__(self, CONSUMER_KEY, CONSUMER_SECRET, access_token)
self.lock = RLock()
self.sig_proxy = SigProxy()
self.username = username
thread = GetUserLists(api=self)
thread.sig_proxy.connect('lists-ready', self.on_lists_ready)
thread.start()
@ -463,5 +465,15 @@ def dms_to_statuses(direct_messages):
return statuses
def get_api(username, password):
def get_access_token():
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)
auth_api = OAuthApi(CONSUMER_KEY, CONSUMER_SECRET, request_token)
return auth_api.getAccessToken()