I am trying to login to a site using python requests. Normally I do this using curl in the cmd.
curl -c <path/urs_cookies.txt> -n -L https://site_FileUpload/login
Where the -n searches for the .netrc file in the cwd which contains my username and password.
However doing this in python using does not work
login = requests.get(url, auth=(username, password))
I believe this is because I need to use my .netrc file instead of using the authorisation method.
Is there anyway I can attach this file to my login request?
Thanks a lot
You don't need to pass .netrc file while requesting via python request library. Only requirement is that
.netrc
file should be in your home directory. I used to trigger a databricks job via python which required all the credentials in.netrc
file. I simply usedrequests.post(url, data)
and kept my.netrc
file in the home directory and it was working.