I am trying to make a POST request to URL , to authenticate myself ( can't share the URL as it is for work). The authentication worked and I got the token access. However , I need to extract the token access header to use it in other function , I don't want to copy the token and paste it .
So , I tried to do this :
response = requests.post(url, data = dic,json={'key':'value'}) # dic is my username and password
token =response.request.headers['AccessToken']
But it is still running , I did not get an error or any output ( I am using Jupyter Notebook)
response = requests.post(url, data = dic) # this one works fine but it does not meet the requirement
Additional clarification : I am asking the user for (username and password) , then I place them into dic which I pass into the POST request.
Example of Server Response :
{"Result":{"AccessToken":"#####="},"Success":true,"Message":"","ErrorCode":""}
Is there other way to access the AccessToken header of the server response ?
Any ideas?
Thank you