diff --git a/src/redfish/rest/v1.py b/src/redfish/rest/v1.py index 2c4b20d..65d910a 100644 --- a/src/redfish/rest/v1.py +++ b/src/redfish/rest/v1.py @@ -977,7 +977,7 @@ def _rest_request(self, path, method='GET', args=None, body=None, else: raise RetriesExhaustedError() from cause_exception - def login(self, username=None, password=None, auth=AuthMethod.SESSION): + def login(self, username=None, password=None, auth=AuthMethod.SESSION, headers={}): """Login and start a REST session. Remember to call logout() when""" """ you are done. @@ -987,6 +987,8 @@ def login(self, username=None, password=None, auth=AuthMethod.SESSION): :type password: str. :param auth: authentication method :type auth: object/instance of class AuthMethod + :param headers: Additional HTTP headers to provide in the request + :type headers: dict, optional """ if getattr(self, "root_resp", None) is None: @@ -1000,7 +1002,6 @@ def login(self, username=None, password=None, auth=AuthMethod.SESSION): self.__password)).encode('utf-8')).decode('utf-8') self.__authorization_key = 'Basic %s' % auth_key - headers = dict() headers['Authorization'] = self.__authorization_key respvalidate = self._rest_request(self.login_url, headers=headers) @@ -1013,7 +1014,6 @@ def login(self, username=None, password=None, auth=AuthMethod.SESSION): data['UserName'] = self.__username data['Password'] = self.__password - headers = dict() resp = self._rest_request(self.login_url, method="POST",body=data, headers=headers, allow_redirects=False)