From 0d0fdbb12b4825c593a73e6e0b31c052fa1bf88e Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 14 Feb 2011 02:59:34 -0500 Subject: [PATCH] Core w/ requests is MUCH simpler --- convore/core.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/convore/core.py b/convore/core.py index ec391dc..dcec3be 100644 --- a/convore/core.py +++ b/convore/core.py @@ -9,6 +9,7 @@ :license: ISC, see LICENSE for more details. """ +import requests __title__ = 'convore' @@ -20,6 +21,9 @@ __copyright__ = 'Copyright 2011 Kenneth Reitz' +API_URL = 'https://convore.com/api/' + + class Convore(object): """The :class:`Convore` object is the heart of this api wrapper. It provides all core functionality. @@ -30,13 +34,21 @@ class Convore(object): """ def __init__(self, username, password): - + self.username = username + self.password = password + + requests.add_autoauth(API_URL, requests.AuthObject(self.username, self.password)) + self.verify() def verify(self): """Authenticates. Returns True if authentication is successful, False if not.""" - pass - -class AuthorizationFailed(Exception): - "Your given username/password was denied access." + r = requests.get(API_URL + 'account/verify.json') + + if r.status_code == 200: + return True + else: + return False + +