forked from python-twitter-tools/twitter
-
Notifications
You must be signed in to change notification settings - Fork 4
/
auth.py
32 lines (25 loc) · 874 Bytes
/
auth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import urllib
from base64 import encodestring
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
if required by the authentication scheme in use."""
raise NotImplementedError()
def generate_headers(self):
"""Generates headers which should be added to the request if required
by the authentication scheme in use."""
raise NotImplementedError()
class NoAuth(Auth):
"""
No authentication authenticator.
"""
def __init__(self):
pass
def encode_params(self, base_url, method, params):
return urllib.urlencode(params)
def generate_headers(self):
return {}