@@ -977,7 +977,7 @@ def _rest_request(self, path, method='GET', args=None, body=None,
977977 else :
978978 raise RetriesExhaustedError () from cause_exception
979979
980- def login (self , username = None , password = None , auth = AuthMethod .SESSION ):
980+ def login (self , username = None , password = None , auth = AuthMethod .SESSION , headers = () ):
981981 """Login and start a REST session. Remember to call logout() when"""
982982 """ you are done.
983983
@@ -987,6 +987,8 @@ def login(self, username=None, password=None, auth=AuthMethod.SESSION):
987987 :type password: str.
988988 :param auth: authentication method
989989 :type auth: object/instance of class AuthMethod
990+ :param headers: Additional HTTP headers to provide in the request
991+ :type headers: dict, optional
990992
991993 """
992994 if getattr (self , "root_resp" , None ) is None :
@@ -1000,7 +1002,6 @@ def login(self, username=None, password=None, auth=AuthMethod.SESSION):
10001002 self .__password )).encode ('utf-8' )).decode ('utf-8' )
10011003 self .__authorization_key = 'Basic %s' % auth_key
10021004
1003- headers = dict ()
10041005 headers ['Authorization' ] = self .__authorization_key
10051006
10061007 respvalidate = self ._rest_request (self .login_url , headers = headers )
@@ -1013,7 +1014,6 @@ def login(self, username=None, password=None, auth=AuthMethod.SESSION):
10131014 data ['UserName' ] = self .__username
10141015 data ['Password' ] = self .__password
10151016
1016- headers = dict ()
10171017 resp = self ._rest_request (self .login_url , method = "POST" ,body = data ,
10181018 headers = headers , allow_redirects = False )
10191019
0 commit comments