xero-python icon indicating copy to clipboard operation
xero-python copied to clipboard

How To Incude Tenant_ID in ProjectsAPI / FileAPI. Authentication Unsuccessful

Open dempstert opened this issue 2 years ago • 3 comments

I am trying to connect to the projects API using this library. I am running into this issue: {"Type":null,"Title":"Forbidden","Status":403,"Detail":"AuthenticationUnsuccessful","Instance":"<my_instance_id>","Extensions":{}}

I am explicitly providing my tenant id, but the API calls still fail. This is only an issue for projects and files.

The same code below will work for invoices, users etc etc.

What I've Tried

from xero import Xero
from xero.auth import OAuth2Credentials

creds = {
    'client_id': ...,
    'client_secret': ...,
    'callback_uri': ...,
    'auth_state': ...,
    'token': {
        ....
    },
    'scope': ['projects', ....]
}
oauth_creds = OAuth2Credentials(**creds)
tenant_id = oauth_creds.tenant_id
oauth_creds.set_default_tenant()

xero = Xero(oauth_creds)
xero.projectsAPI.projects.all()

Result

{"Type":null,"Title":"Forbidden","Status":403,"Detail":"AuthenticationUnsuccessful","Instance":"<my_instance_id>","Extensions":{}}

Note The following WILL work

xero.users.all()

dempstert avatar Jul 20 '23 02:07 dempstert

PETOSS-316

github-actions[bot] avatar Jul 20 '23 02:07 github-actions[bot]

Thanks for raising an issue, a ticket has been created to track your request

github-actions[bot] avatar Jul 20 '23 02:07 github-actions[bot]

Hi @dempstert , can you provide the name of your Xero app or tenant? Any Xero-Correlation-Id from a response header would work as well.

rdemarco-xero avatar Jul 20 '23 18:07 rdemarco-xero