webfox / laravel-xero-oauth2

A Laravel integration for Xero using the Oauth 2.0 spec
MIT License
50 stars 32 forks source link

Xero API Get Invoices Returns 401 Unauthorized` response #99

Closed manugentoo closed 3 months ago

manugentoo commented 3 months ago

Hello there,

I'm using your package and im trying to list an invoice from a tenantID code goes like:

` if ($xeroCredentials->exists()) { $xero = resolve(\XeroAPI\XeroPHP\Api\AccountingApi::class); $tenantId = $xeroCredentials->getTenantId();

// this returns data $organisationName = $xero->getOrganisations(tenantId)

// this throws exception $xero->getInvoices($tenantId } `

that block of code returns

XeroAPI\XeroPHP\ApiException [401] Client error:GET https://api.xero.com/api.xro/2.0/Invoices?summaryOnly=falseresulted in a401 Unauthorizedresponse: {"Type":null,"Title":"Unauthorized","Status":401,"Detail":"AuthorizationUnsuccessful","Instance":"3fcae45a-0ee2-4078-b83 (truncated...)

any idea why?

manugentoo commented 3 months ago

Resolved this by adding: 'accounting.transactions' in 'scopes' of config/xero.php