title: Python script to get Session Ticket
body: <p>I have a service, that exposes API for logging in. In my browser if I do</p>
  
  <pre><code>&lt;host&gt;:&lt;port&gt;/myservice/api/login?u=admin&amp;pw=admin
  </code></pre>
  
  <p>The above url, returns a ticket, that I can pass along for my successive requests. </p>
  
  <p><a href="https://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Login" rel="nofollow">More details about the same, here.</a></p>
  
  <p>Below is my python script.</p>
  
  <pre><code>import urllib
  
  url = 'http://&lt;host&gt;:&lt;port&gt;/myservice/api/login?u=admin&amp;pw=admin'
  print 'Retrieving', url
  uh = urllib.urlopen(url)
  data = uh.read()
  print 'Retrieved',len(data),'characters'
  print data
  </code></pre>
  
  <p>When I run this I get</p>
  
  <pre><code>IOError: ('http error', 401, 'Authorization Required', &lt;httplib.HTTPMessage instance at 0x&lt;somenumber&gt;&gt;)
  </code></pre>
  
  <p>Now, I am not sure what am I supposed to do. So I went to my browser, and opened the developer's console. </p>
  
  <p>Apparently, the url has moved to something else. I see two requests.</p>
  
  <p>first one hits the url that I am hitting. Response Header has a Location:Parameter.</p>
  
  <p>The second request hits the url that is returned as Location parameter. the Authorization header has 'Negotiation 
  
  <p>It also has a setcookie in the response header.</p>
  
  <p>Now, I am not sure what exactly to do with this information, but if someone can help. Thanks</p>