1010
1111class AuthenticationBase (object ):
1212 """A base authentication class intended to be overridden."""
13- def get_headers (self ):
14- """Return a dictionary of headers to be inserted for authentication ."""
13+ def get_options (self , options ):
14+ """Receives request options and returns request options ."""
1515 raise NotImplementedError
1616
1717
@@ -26,15 +26,14 @@ def __init__(self, user_id, auth_token):
2626 self .user_id = user_id
2727 self .auth_token = auth_token
2828
29- def get_headers (self ):
30- """Returns token-based auth headers."""
31- return {
32- 'authenticate' : {
33- 'complexType' : 'PortalLoginToken' ,
34- 'userId' : self .user_id ,
35- 'authToken' : self .auth_token ,
36- }
29+ def get_options (self , options ):
30+ """Sets token-based auth headers."""
31+ options ['headers' ]['authenticate' ] = {
32+ 'complexType' : 'PortalLoginToken' ,
33+ 'userId' : self .user_id ,
34+ 'authToken' : self .auth_token ,
3735 }
36+ return options
3837
3938 def __repr__ (self ):
4039 return "<TokenAuthentication: %s %s>" % (self .user_id , self .auth_token )
@@ -50,14 +49,13 @@ def __init__(self, username, api_key):
5049 self .username = username
5150 self .api_key = api_key
5251
53- def get_headers (self ):
54- """Returns token-based auth headers."""
55- return {
56- 'authenticate' : {
57- 'username' : self .username ,
58- 'apiKey' : self .api_key ,
59- }
52+ def get_options (self , options ):
53+ """Sets token-based auth headers."""
54+ options ['headers' ]['authenticate' ] = {
55+ 'username' : self .username ,
56+ 'apiKey' : self .api_key ,
6057 }
58+ return options
6159
6260 def __repr__ (self ):
6361 return "<BasicAuthentication: %s>" % (self .username )
0 commit comments