title: authentication using httplib in python
body: <p>I am using python 2.7.10. How can I login using httplib connection method.</p>
  
  <pre><code>import httplib
  conn = httplib.HTTPConnection("192.18.33.10")
  conn.request("POST", "/user/user.form?name=Maharjun&amp;age=23")
  res = conn.getresponse()    
  data = res.read()
  </code></pre>
  
  <p><strong>What this user.form does is</strong>, it will accept some details like name and age from users and server will save them in database. This details can only filled by authenticated users. </p>
  
  <p>I tried some suggestions from python http.requests but those are not working in python-2.7.10.</p>
  
  <p>I know about postman. So, I sent same request in postman using basic authentication method and i converted that into python scripts. In postman we can convert postman-URL into curl/shell/python scripts. So, I converted them into python scripts. </p>
  
  <p><strong>Both are same requests. But I am able to submit the data using postman. But not able to do with python.</strong></p>
  
  <p>postman is giving me a post-man token and basic authentication in headers like below code. is there any mistakes in the code or any suggestions?</p>
  
  <pre><code>import httplib
  conn = httplib.HTTPConnection("192.18.33.10")
  url = "/user/user.form?name=Maharjun&amp;age=23"
  headers = {
      'authorization': "Basic some-token",
      'cache-control': "no-cache",
      'postman-token': "some-token"
      }
  response = conn.request("POST", url, headers=headers)
  print(response.text)
  </code></pre>
  
  <p>Though it have <strong><em>'authorization'</em></strong> token I was not able to login by using above code.</p>
  
  <p>can someone help me to write basic authentication using python requests.?</p>