title: Yggdrasil authentication with Python
body: <p>I decided to try to make an automated login script for Minecraft. However, the new authentication API is stumping me. I can't find any mentions of the new functionality of the API on here. This is my code as it stands:</p>
  
  <pre><code>import requests
  import json
  
  data = json.dumps({"agent":{"name":"Minecraft","version":1},"username":"abcdef","password":"abcdef","clientToken":""})
  headers = {'Content-Type': 'application/json'}
  r = requests.post('https://authserver.mojang.com', data=data, headers=headers)
  
  print (r.text)
  </code></pre>
  
  <p>Unfortunately, this returns:</p>
  
  <pre><code>{"error":"Method Not Allowed","errorMessage":"The method specified in the request is not allowed for the resource identified by the request URI"}
  </code></pre>
  
  <p>According to <a href="http://wiki.vg/Authentication" rel="nofollow">this</a> resource on request format, this error means that I didn't correctly send a post request. However, I clearly declared <code>requests.post()</code>, so my first question is how am I incorrect, and what is the correct way to go about this?</p>
  
  <p>My second question is, since I'm relatively new to Python and JSON, how would I replace the username and password fields with my own data, inside a variable?</p>