Please see below for fix.
Manager:
public function fetchAndParseXero(AccountXero $accountXero, ConnectionXero $connectionXero, string $date)
{
try {
$this->logger->info("Fetching accounts from Xero.");
$tenantId = "test123";
$apiInstance = $this->xeroApiClient->initXeroClient();
$response = $apiInstance->getAccounts($tenantId);
var_dump($response);
} catch (\Exception $e) {
$this->logger->error("Error fetching trial balance from Xero. ERROR: {$e->getMessage()}");
}
}
Client:
public function initXeroClient(): AccountApi
{
$accessToken = "test123";
$config = Configuration::getDefaultConfiguration()->setAccessToken($accessToken);
$guzzleClient = new Client();
return new AccountApi(
$guzzleClient,
$config
);
}
Now thats fixed. My next issue is that I always get 401 Unauthorized response when trying to get TrialBalance. Both in postman and code. The scope of my authorization already has the finance.statements.read scope. What else is missing ?