mirror of
https://github.com/kennethreitz-archive/python-convore.git
synced 2026-06-05 23:40:18 +00:00
Core w/ requests is MUCH simpler
This commit is contained in:
+17
-5
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user