A new library for storing app keys is added

This commit is contained in:
2015-02-04 17:00:03 -06:00
parent 2a7e09b166
commit 62b0bc76a8
10 changed files with 78 additions and 16 deletions

View File

@@ -2,24 +2,25 @@
import BaseHTTPServer
import webbrowser
from twython import Twython, TwythonError
import application
from keys import keyring
import authorisationHandler
class twitter(object):
def login(self, user_key, user_secret):
self.twitter = Twython(application.app_key, application.app_secret, user_key, user_secret)
self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), user_key, user_secret)
self.credentials = self.twitter.verify_credentials()
def authorise(self, settings):
httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', 8080), authorisationHandler.handler)
twitter = Twython(application.app_key, application.app_secret, auth_endpoint='authorize')
twitter = Twython(keyring.get("app_key"), keyring.get("app_secret"), auth_endpoint='authorize')
auth = twitter.get_authentication_tokens("http://127.0.0.1:8080")
webbrowser.open_new_tab(auth['auth_url'])
# global logged, verifier
while authorisationHandler.logged == False:
httpd.handle_request()
self.twitter = Twython(application.app_key, application.app_secret, auth['oauth_token'], auth['oauth_token_secret'])
self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth['oauth_token'], auth['oauth_token_secret'])
final = self.twitter.get_authorized_tokens(authorisationHandler.verifier)
self.save_configuration(settings, final["oauth_token"], final["oauth_token_secret"])