Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/redfish/rest/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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)

Expand Down