I have the following code in C# that works perfectly at authenticating the user (reponse 200):
using (var client = new HttpClient(new HttpClientHandler { UseDefaultCredentials = true }))
{
HttpResponseMessage response = client.PutAsync(url,content).GetAwaiter().GetResult();
}
I want to do the same thing natively in Python, though the asynchronous call isn't important to me. I've tried:
import requests
headers = {'Content-type': 'application/json'}
r = requests.put(my_url,my_unicode_object,headers=headers,verify=False,auth=(username,pass))
However I get a 401 unauthorized response. I have all my C# variables to compare side-by-side and I still don't know how to get the same working in Python.
Update: In VS when I type "System.Net.CredentialCache.DefaultNetworkCredentials" I get the following:
Domain: ""
Password: ""
SecurePassword: {System.Security.SecureString}
UserName: ""
I don't think it's actually using any credentials, but with I try not using auth or auth = ('','') the http put request still gives a 401 request response.