Home > Software design >  is there a specific payload format for <https://authserver.mojang.com/authenticate>?
is there a specific payload format for <https://authserver.mojang.com/authenticate>?

Time:10-31

I am currently trying to write code to find out what has changed for the authentication of migrated accounts for Minecraft and this is my code.

import requests
from uuid import uuid4

uuid = uuid4().hex   #used as client token

payload = {
    "agent": {
        "name": "Minecraft",
        "version": 1
    },
    "username": "[email protected]",
    "password": "APasswordToTheAccount",
    "clientToken": uuid,
    "requestUser": True
}

print(requests.post("https://authserver.mojang.com/authenticate", headers = {"content-type":"application/json"}, data = payload))

Every time I run it I get a 400 error code, I should be getting an appropriate, non-200 HTTP status code or a JSON-encoded dictionary.

my resources are 
<https://wiki.vg/Mojang_API> , 
<https://wiki.vg/Authentication> , 
and the mojangapi library <https://pypi.org/project/mojang-api/>

CodePudding user response:

Try this line instead:

print(requests.post("https://authserver.mojang.com/authenticate", json=payload))

You weren't sending the JSON the right way.

  • Related