Reputation: 45
I am using the REST API for iObeya, I wish to use Python Requests but currently I cannot authenticate with the server. The documentation states that you can authenticate using a POST request and upon return, you should get a cookie called 'JSESSIONID' when the auth is correct.
So far I have this:
url = 'https://link-to.com/iobeya/'
auth_url = 'https://link-to.com/iobeya/j_spring_security_check'
headers = {"content-type": "application/x-www-form-urlencoded; charset=utf-8"}
session = requests.Session()
session.auth = ("username", "password")
auth = session.post(url, verify=False)
r = session.get(url, verify=False, headers=headers)
print(r.status_code)
print(r.headers)
print(r.cookies)
The return of cookies is null. Is this the right way to be doing a auth request using a POST method?
Here is the page describing how the auth API works:
Upvotes: 0
Views: 609
Reputation: 599956
It just wants you to make a normal POST with username
and password
.
auth_url = 'https://link-to.com/iobeya/j_spring_security_check'
session = requests.Session()
auth = session.post(auth_url, data={'username': username, 'password': password})
Upvotes: 2