Server returns 403 Forbidden error on auth step
I was receiving this error during login:
PHP Fatal error: Uncaught JsonException: Syntax error in /home/shafeey/fut-api/src/Api/AbstractCore.php:339
Stack trace:
#0 /home/shafeey/fut-api/src/Api/AbstractCore.php(339): json_decode('', true, 512, 4194304)
#1 /home/shafeey/fut-api/test.php(37): Shapecode\FUT\Client\Api\AbstractCore->login('881689')
As I looked deeper, I found that the POST request to "https://utas.external.s2.fut.ea.com:443/ut/auth?client=webcomp" is returning 403 FORBIDDEN with an empty body, which in turn results in the json_decode() exception. https://github.com/shapecode/fut-api/blob/4df924ca96e4f33ae6811f576c0e8c3fa599d6f5/src/Api/AbstractCore.php#L313
I'm using the following script for login and putting the code from verification email. Any idea what I am doing wrong? Thank you.
<?php
// Autoload files using the Composer autoloader.
require_once __DIR__ . '/vendor/autoload.php';
use Shapecode\FUT\Client\Api\Core;
use Shapecode\FUT\Client\Exception\FutError;
use Shapecode\FUT\Client\Authentication\Account;
use Shapecode\FUT\Client\Authentication\Credentials;
use Shapecode\FUT\Client\Authentication\Session;
$email = "[email protected]";
$password = "PASSWD";
$platform = "ps4";
$code = "999999";
$credentials = new Credentials($email, $password, $platform);
$session = null;
$account = new Account($credentials, $session);
$fut = new Core($account);
try {
$login = $fut->login($code);
$session = $account->getSession();
} catch(FutError $e) {
$reason = $e->getReason();
die("We have an error logging in: ".$reason);
}
echo "Login complete...\n";
I can't really help you as I'm unable to replicate the issue. What version of fut-api are you on?
Hi, @shafeey I had the same error and I understand how to fix it in my situation. Quick fix is to check and modify the line. https://github.com/shapecode/fut-api/blob/4df924ca96e4f33ae6811f576c0e8c3fa599d6f5/src/Api/AbstractCore.php#L281
In case you have more than one account used on different platforms here you just get the first array element. You can use Curtis old logic or implement your own.
At that moment my quick fix is
$persona_id = null; foreach ($personasValues as $personasValue) { if ($personasValue['onlineAccess']) { $persona_id = $personasValue['personaId']; } }
@nicklog Can you check Telegram. I sent you a message.
@serggi Would you make a PR so we can add a fix for that.