Answer the question
In order to leave comments, you need to log in
How to solve Mojang API authorization issue?
Wrote an authorization script to verify a Mojang account.
$post_data = array (
"Username" => "[email protected]",
"Password" => "Dominicc1599",
"ClientToken" => "7c825a05-817a-4aad-939e-02c9dd3d923a"
);
$ch = curl_init("https://authserver.ely.by/auth/authenticate");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 4);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
Answer the question
In order to leave comments, you need to log in
If you read the original mojang.com doc, you can see that the guys from ely.by tore it up with fundamental mistakes:
- they forgot that the parameters must be passed in json (however, application/x-www-form-urlencoded
it also works);
- for some reason they renamed all the parameters with a capital letter.
Request
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://authserver.ely.by/auth/authenticate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{\n\t\"username\":\"[email protected]\",\n\t\"password\":\"Dominicc1599\",\n\t\"clientToken\":\"7c825a05-817a-4aad-939e-02c9dd3d923a\"\n}",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
{
"error": "ForbiddenOperationException",
"errorMessage": "Invalid credentials. Invalid email or password."
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question