X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/568331a954966fe0a980523b98f5195cc1026c5c..7f22c0211d8f3cc0efc56533b98354cc8f3aecac:/twitter/auth.py diff --git a/twitter/auth.py b/twitter/auth.py index e441d5b..f22b088 100644 --- a/twitter/auth.py +++ b/twitter/auth.py @@ -1,7 +1,11 @@ import urllib from base64 import encodestring -class Auth: +class Auth(object): + """ + ABC for Authenticator objects. + """ + def encode_params(self, base_url, method, params): """Encodes parameters for a request suitable for including in a URL or POST body. This method may also add new params to the request @@ -13,8 +17,12 @@ class Auth: by the authentication scheme in use.""" raise NotImplementedError -# An implementation using username and password. + class UserPassAuth(Auth): + """ + Basic auth authentication using email/username and + password. Deprecated. + """ def __init__(self, username, password): self.username = username self.password = password @@ -27,3 +35,13 @@ class UserPassAuth(Auth): def generate_headers(self): return {"Authorization": "Basic " + encodestring("%s:%s" %( self.username, self.password)).strip('\n')} + +class NoAuth(UserPassAuth): + """ + No authentication authenticator. + """ + def __init__(self): + pass + + def generate_headers(self): + return {}