Python Forum
Need help in adding xsrf token - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Need help in adding xsrf token (/thread-20387.html)



Need help in adding xsrf token - keerthiprashanth - Aug-08-2019

Hi All,

Below is my requirement and below is my code.

When we post the request to some API via API calls a cookie session will be created on each API call and all the sessions ID, tokens are unique each time. XSRF token is to establish the session with the particular URL for further working sessions with it. The requirement is we just need only to extract the XSRF token from the output

import requests

import json

import os

HOST = 'https://console.cloudendure.com/api/v5/login'

#api_token = '4bbe1c1c-4c67-4603-886b-9d842ccef12a'

headers = {

'userApitoken' : '4bbe1c1c-4c67-4603-886b-9d842ccef12a'

    }

endpoint = '/api/v5/'

session = requests.Session()

session.headers.update({'Content-type': 'application/json', 'Accept': 'text/plain'})

resp = session.post(url=HOST, data=json.dumps({'username': '[email protected]', 'password': 'Password123'}))

response = resp.cookies

print(response)



RE: Need help in adding xsrf token - keerthiprashanth - Aug-08-2019

Can someone please help me on this