Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

Xero.NetStandard.OAuth2 - Scope accounting.settings 401 Unauthorized

Started by Mark Brightenfield -   in Wrapper libraries

I am currently using Xero.NetStandard.OAuth2 {3.0.0} (C#) and am having trouble with any methods that require the accounting.settings scope such as GetOrganizationsAsync and GetTrackingCategoriesAsync. I proceed to receive 401 Unauthorized errors when attempting any methods that require the accounting.settings scope even though I do include this scope in the config.

I am able to use methods from other scopes successfully (accounting.transactions, accounting.contacts):
Ex:
- GetInvoicesAsync
- UpdateOrCreateContactsAsync
- UpdateOrCreateInvoicesAsync
- CreatePaymentsAsync
- CreateCreditNotesAsync

However, methods that require accounting.settings scope return 401. Searching the dev community and github for similar issues all point to the accounting.settings scope missing. However, I'm including the accounting.settings scope and am still receiving 401 errors.

Might there be something else I'm missing other than scope?
Scope should be all you need. Are you 100% sure you fully regenerated a new token_set once you added the scope and created a new Xero.NetStandard client?

Once you have the token_set head over to https://jwt.io/ and paste in your access_token - that will very clearly show you which scopes the user agreed to on the auth screen.
 

Christopher Knight (Xero Staff)  

Christopher,

Thank you for this. I was able to confirm with jwt.io that the accounting.settings permission was, in fact, missing from the scope in the access token. It would appear that an older access token was being used which was created prior to adding accounting.settings to the scope in the config. Blowing away the token and creating a new one solved the issue.

Thank you!
 

Mark Brightenfield  

Glad you got that sorted!
 

Christopher Knight (Xero Staff)