Login credential issue

Hi, I tried to log in to My RT account and tried to get my account details using API from my python script. I am adding the python code below

url = “http://rt.reflectionsinfo.com/?user=” + username + “&pass=” + password
payload = “”
headers = {
‘Cookie’: ‘RT_SID_rt.reflectionsinfo.com.80=fc2116343824f888681d9261d0fea3f1’,
‘Content-Type’: ‘text/plain’

response = requests.request(“POST”, url, headers=headers, data=payload, verify=False)
This is my login API and it’s working fine. After login I tried to get my user details using following API
url = “https://rt.reflectionsinfo.com//REST/1.0/user/”+username
payload = {}
headers = {
‘Cookie’: ‘RT_SID_rt.reflectionsinfo.com.80=fc2116343824f888681d9261d0fea3f1’
response = requests.request(“GET”, url, headers=headers, data=payload, verify = False)

Here I am getting the response that “Credentials Needed”. But I already log in using my credentials.
So I tried one more time from POSTMAN using login API and using the new cookie got from the postman into the URL to get user details. Now it’s working. Why this happened. Can’t we directly login from our python code and get the user details using the API. Can Someone please help me?

When you did the initial REST 1.0 call with user and password set, did the response from the RT server include a new session cookie in the headers?

yes getting a cookie in the response

And it’s the same Session Cookie as you’re using in the second request, which appears to be a pre-existing session cookie you’re sending in the first request?

Now tried with the cookie which is getting in the response header of login and it’s working now. User details are getting now. Thank you for the response

I have one more doubt that currently for every login I am using the same preexisting cookie. Do I need to create any custom cookie their too. Is it any way for that?

You shouldn’t need a cookie for the initial authentication request - that’s logging you in with user/pass and then generating the cookie for you to use in subsequent API calls.

Ok. Thank you for the responses