title: How do I pass the username/password to authenticate a POST request to a Django rest-framework API from python code?
body: <p>this is the request I want to emulate in python code, made here with httpie</p>
  
  <pre><code>$ http --auth mucho:pass POST http://3333333.ngrok.io/sms/ msg="love conquers all" to="255123456"
  HTTP/1.1 201 Created
  Allow: GET, POST, HEAD, OPTIONS
  Content-Length: 67
  Content-Type: application/json
  Date: Mon, 30 Dec 2019 20:31:33 GMT
  Server: WSGIServer/0.2 CPython/3.7.5
  Vary: Accept, Cookie
  X-Content-Type-Options: nosniff
  X-Frame-Options: DENY
  
  {
      "id": 70,
      "msg": "love conquers all",
      "owner": "mucho",
      "to": "255123456"
  }
  </code></pre>
  
  <p>I have tried this</p>
  
  <pre><code>from requests import Request,Session
  url="http://3333333.ngrok.io/sms/"
  data = {
      "to": "255123456",
      "msg": "love conquers all",
      }
  s=Session()
  req=Request('POST',url,data=data)
  preped=req.prepare()
  preped.prepare_auth(("mucho","pass"),url)
  resp=s.send(preped)
  </code></pre>
  
  <p>It works, but I am looking for a neater/simpler way possibly using headers. Thanks for any help my way</p>