I'm trying to write a code which collects data from website using REST API.
There is an authentication and I correctly send POST request (let's name it LogIn) with credentials and correct response. Then, I would like to call another POST command (let's name it GetData), but I get "Unauthorized: Access is denied due to invalid credentials."
I'm using python requests.session() to keep all cookies and I've noticed something wired. If I log in the web browser and replace ASP.NET_SessionId cookie in my python GetData request (like that: self.session.cookies.update({'ASP.NET_SessionId': 'XXX'})) the response is correct.
I've checked and python LogIn request also generates ASP.NET_SessionId cookie but somehow it is not valid and only if I copy it from browser it is correct.
You do not keep/send the authentication cookie from login to the next call.
When you call the login page the login is answer with an authentication cookie, and maybe with a session cookie.
On the next call you have to provide this two cookies to been able to get the data - the one is assure that you have the permissions to read them
ASP.NET_SessionId access denied