title: Getting security token with requests
body: <p>Trying to use requests to get a token from an appspace server .
  Works in curl, works from DHC chrome extension but can't get  code to work.
  More than likely something dumb I've missed or doing.</p>
  
  <p><a href="https://knowledgecenter.appspace.com/5-4/other-resources/developer-guides/appspace-graph-api-examples" rel="nofollow">https://knowledgecenter.appspace.com/5-4/other-resources/developer-guides/appspace-graph-api-examples</a>
  <a href="https://knowledgecenter.appspace.com/5-4/other-resources/developer-guides/appspace-graph-api" rel="nofollow">https://knowledgecenter.appspace.com/5-4/other-resources/developer-guides/appspace-graph-api</a></p>
  
  <p>I've tried</p>
  
  <pre><code>url = 'http://10.2.3.205/api/v1/token/request'
  headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
  
  data = {"Authentication" :
   {"Username": "email@company.com",
    "Password": "password"
   }
  }
  
  r = requests.get(url, auth=(data), headers=headers)
  
  print r.status_code
  print r.headers['content-type']
  </code></pre>
  
  <p>which gives a dict object not callable error</p>
  
  <p>also get the same error with</p>
  
  <pre><code>auth = {"Username": "email@company.com",
        "Password": "password"
       }
  </code></pre>
  
  <p>also tried </p>
  
  <pre><code>    auth = {"Authentication" :
   {"Username": "email@company.com",
    "Password": "password"
   }
  }
      r = requests.post(url, params=auth, headers=headers)
  </code></pre>
  
  <p>which gives </p>
  
  <pre><code>200
  application/json; charset=utf-8
  {"Errors":[{"Code":"500","Message":"Token request object is null"}],"Status":2}
  </code></pre>
  
  <p>and more directly with</p>
  
  <pre><code>r = requests.get(url, auth=("email@company.com", "password" ), headers=headers)
  </code></pre>
  
  <p>which gives</p>
  
  <pre><code>405
  text/html; charset=UTF-8
  </code></pre>
  
  <p>and a few other ways as well which give 405 errors as well.</p>
  
  <p>curl gets the token</p>
  
  <pre><code>$ curl -i -X POST    -H "Accept:application/json"    -H "Content-Type:application/json"    -d '{"Authentication" :                 
   {"Username": "email@company.com",
    "Password": "password"
   }
  }'  'http://10.2.3.205/api/v1/token/request'
  HTTP/1.1 200 OK
  Cache-Control: private
  Content-Length: 67
  Content-Type: application/json; charset=utf-8
  Server: Microsoft-IIS/7.5
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  Date: Tue, 03 Mar 2015 14:21:17 GMT
  
  {"Status":1,"SecurityToken":"valid token string"}
  </code></pre>
  
  <p>Thank you</p>