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