79415718

Date: 2025-02-05 17:58:51
Score: 1.5
Natty:
Report link

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 ?

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Angi