Mar-09-2024, 07:00 AM
I make my request from a server:
'SessionToken': 'UVFlMTJJSENVTllpdThOR3hrZVpPY2dPQUR0c2MwZWtMYWFRdWZKam50S1AwRmVZNWZ0ZUliRENDbWFZNnJFUTJ3K2YzRmZxNVFXRk5USEJIcCtvUWc9PQ==', 'Set-Cookie': 'SessionToken="QQe12IHCUNYiu8NGxkeZOcgOADtsc0ekLaaQufJjntKP0FeY5fteIbDCCmaY6rEQ2w+f3Ffq5QWFNTHBHp+oQg=="
Now I want to make more requests with
'session_token': 'UVFlMTJJSENVTllpdThOR3hrZVpPY2dPQUR0c2MwZWtMYWFRdWZKam50S1AwRmVZNWZ0ZUliRENDbWFZNnJFUTJ3K2YzRmZxNVFXRk5USEJIcCtvUWc9PQ=='
How do I code in order use the header information originally provided by the server?
thank you.
first post
obj = requests.Session() response = obj.request('get','https://192.168.0.22/api/', auth = HTTPBasicAuth(userName, password), verify = False) print(response.headers)Here is the first part of the returned header; the server creates the session token:
'SessionToken': 'UVFlMTJJSENVTllpdThOR3hrZVpPY2dPQUR0c2MwZWtMYWFRdWZKam50S1AwRmVZNWZ0ZUliRENDbWFZNnJFUTJ3K2YzRmZxNVFXRk5USEJIcCtvUWc9PQ==', 'Set-Cookie': 'SessionToken="QQe12IHCUNYiu8NGxkeZOcgOADtsc0ekLaaQufJjntKP0FeY5fteIbDCCmaY6rEQ2w+f3Ffq5QWFNTHBHp+oQg=="
Now I want to make more requests with
'session_token': 'UVFlMTJJSENVTllpdThOR3hrZVpPY2dPQUR0c2MwZWtMYWFRdWZKam50S1AwRmVZNWZ0ZUliRENDbWFZNnJFUTJ3K2YzRmZxNVFXRk5USEJIcCtvUWc9PQ=='
def make_authenticated_request(url, session_token): headers = {'Authorization': 'Bearer ' + session_token} response = requests.get(url, headers=headers, verify = False)my status code returns 401. What am I dong wrong?
How do I code in order use the header information originally provided by the server?
thank you.
first post