Fixed credential verification with Basic (HTTP) Auth; previously, it assumed that passing in credentials meant you knew what you were doing. I take full blame for that act of idiocracy, but it's fixed now.

This commit is contained in:
Ryan McGrath 2009-07-02 03:56:24 -04:00
parent b82f88c101
commit 76ca83cb87
2 changed files with 14 additions and 2 deletions

View file

@ -40,7 +40,13 @@ class setup:
self.auth_manager.add_password(None, "http://twitter.com", self.username, self.password)
self.handler = urllib2.HTTPBasicAuthHandler(self.auth_manager)
self.opener = urllib2.build_opener(self.handler)
self.authenticated = True
try:
test_verify = simplejson.load(self.opener.open("http://twitter.com/account/verify_credentials.json"))
self.authenticated = True
except HTTPError, e:
if self.debug is True:
print e.headers
print "Huh, authentication failed with your provided credentials. Try again? (" + str(e.code) + " failure)"
# OAuth functions; shortcuts for verifying the credentials.
def fetch_response_oauth(self, oauth_request):

View file

@ -42,7 +42,13 @@ class setup:
self.auth_manager.add_password(None, "http://twitter.com", self.username, self.password)
self.handler = urllib.request.HTTPBasicAuthHandler(self.auth_manager)
self.opener = urllib.request.build_opener(self.handler)
self.authenticated = True
try:
test_verify = simplejson.load(self.opener.open("http://twitter.com/account/verify_credentials.json"))
self.authenticated = True
except HTTPError as e:
if self.debug is True:
print(e.headers)
print("Huh, authentication failed with your provided credentials. Try again? (" + str(e.code) + " failure)")
# OAuth functions; shortcuts for verifying the credentials.
def fetch_response_oauth(self, oauth_request):