0

I have found an API class (https://github.com/eddieharrison/sageone-api-php) in PHP for the SageOne Accounts Cloud Software.

I used the code found in auth.php with my apps CLIENT_ID and CLIENT_SECRET to gain an access code.

I then tried this code (/examples/get-ledger-accounts.php):

define('SAGE_CLIENT_ID', 'my client id');
define('SAGE_CLIENT_SECRET', 'my client secret');

// If you do not already have an access token please see:
// /examples/auth.php
define('SAGE_ACCESS_TOKEN', 'access code from auth.php');

$client = new SageOne(SAGE_CLIENT_ID, SAGE_CLIENT_SECRET);
$client->setAccessToken(SAGE_ACCESS_TOKEN);
$result = $client->getLedgerAccounts();
echo '<pre>';
print_r($result);
echo '</pre>';

however when testing this code, i get the following:

string(26) "{"error":"invalid_token"} " int(0)
Array
(
    [error] => invalid_token
)

Does anyone know what this means and how i can fix it to gain access to our accounts data from SageOne?

Christoph Petschnig
  • 4,047
  • 1
  • 37
  • 46
CharlesF
  • 169
  • 1
  • 1
  • 11

2 Answers2

0

Assuming you have signed up via developers.sageone.com, an invalid_token error is expected if you try to use the token beyond the expiration time, which is 1 hour after issuance.

Another thing I noticed is that the library you mentioned does not support the request signing which is required.

Tobscher
  • 159
  • 1
  • 5
0

Are you working on a client app or accounting integration?

I've put up a wrapper for the Sage One Accounting API v 1.1.1, which uses an Api Key instead of clientId / accessToken. This will work better if you're going for automation.

https://github.com/Sharnw/sage-one-accounting-api

API docs here: https://accounting.sageone.co.za/Marketing/DeveloperProgram.aspx

Sharn White
  • 624
  • 3
  • 15