import urllib as urllib_parse
from base64 import encodestring as encodebytes
+
class Auth(object):
"""
ABC for Authenticator objects.
by the authentication scheme in use."""
raise NotImplementedError()
+
class UserPassAuth(Auth):
"""
Basic auth authentication using email/username and
.encode('utf8')).strip(b'\n')
}
+
class NoAuth(Auth):
"""
No authentication authenticator.
def generate_headers(self):
return {}
+
+
+class MissingCredentialsError(Exception):
+ pass
import hmac
import base64
-from .auth import Auth
+from .auth import Auth, MissingCredentialsError
def write_token_file(filename, oauth_token, oauth_token_secret):
self.consumer_key = consumer_key
self.consumer_secret = consumer_secret
+ if token_secret is None or consumer_secret is None:
+ raise MissingCredentialsError(
+ 'You must supply strings for token_secret and consumer_secret, not None.')
+
def encode_params(self, base_url, method, params):
params = params.copy()
from urllib import quote, urlencode
from base64 import b64encode
-from .auth import Auth
+from .auth import Auth, MissingCredentialsError
def write_bearer_token_file(filename, oauth2_bearer_token):
"""
).encode('utf8')
}
return headers
-
-
-class MissingCredentialsError(Exception):
- pass