]> jfr.im git - z_archive/twitter.git/blame - twitter/auth.py
import fix for py2
[z_archive/twitter.git] / twitter / auth.py
CommitLineData
3930cc7b
MV
1try:
2 import urllib.parse as urllib_parse
3except ImportError:
84d17de6 4 import urllib as urllib_parse
3930cc7b 5
568331a9
MH
6from base64 import encodestring
7
1cc9ab0b
MV
8class Auth(object):
9 """
10 ABC for Authenticator objects.
11 """
12
568331a9
MH
13 def encode_params(self, base_url, method, params):
14 """Encodes parameters for a request suitable for including in a URL
15 or POST body. This method may also add new params to the request
16 if required by the authentication scheme in use."""
aec68959 17 raise NotImplementedError()
568331a9
MH
18
19 def generate_headers(self):
20 """Generates headers which should be added to the request if required
21 by the authentication scheme in use."""
aec68959 22 raise NotImplementedError()
568331a9 23
1cc9ab0b 24
aec68959 25class NoAuth(Auth):
1cc9ab0b
MV
26 """
27 No authentication authenticator.
28 """
d20da7f3
MV
29 def __init__(self):
30 pass
31
aec68959 32 def encode_params(self, base_url, method, params):
3930cc7b 33 return urllib_parse.urlencode(params)
aec68959 34
d20da7f3
MV
35 def generate_headers(self):
36 return {}