5

I am currently trying to retrieve the account details for the list of accounts using the following API endpoint : https://api.xero.com/api.xro/2.0/Accounts.

I have the following scopes included:
openid profile email accounting.transactions accounting.reports.read accounting.contacts.read.

I am however receiving the following error:

    [Title] => Unauthorized   
    [Status] => 401   
    [Detail] => AuthorizationUnsuccessful   

Thanks

the_big_blackbox
  • 1,056
  • 2
  • 15
  • 35

1 Answers1

6

The full list of scopes can be found here: https://developer.xero.com/documentation/oauth2/scopes

You'll find that accounting.settings and accounting.settings.read scopes give access to the Accounts endpoint

MJMortimer
  • 865
  • 5
  • 10
  • Thanks, I did have a look at that page just happened to miss that scope. – the_big_blackbox Apr 05 '20 at 19:25
  • I don't see `xero.settings`, only `accounts.settings`. `accounts.settings.read` is not giving me access to get /Accounts – Ade Nov 15 '21 at 14:17
  • As of July 2022, it's `accounting.settings.read`. BTW, it seems that when connecting to a company owned by the same person as the OAuth app, the scopes are not necessary, which is very confusing. I didn't run into the 401 error myself, instead the client did when testing. For me the API returns the account data without the necessary scope. – Rafał G. Jul 07 '22 at 07:55
  • @RafałG. Will this be due to the additive nature of the Xero API scopes? https://developer.xero.com/documentation/guides/oauth2/scopes/#scopes-are-additive – MJMortimer Jul 10 '22 at 22:16
  • @MJMortimer Not really, the issue wasn't with needing some scopes before and then more scopes later. But my app works now, I'm just saying that the development process was glitchy. – Rafał G. Jul 12 '22 at 06:21
  • Just to add to this, the Xero API Explorer (available once logged in via browser) shows you the required scopes for each specific request. Get Accounts currently requires scopes `accounting.settings | accounting.settings.read` – JamesP Oct 18 '22 at 09:58