0

我正在尝试在 python 中调用 xero Accounts api,但由于某种原因无法正常工作。它适用于其他 API,例如 Invoices、reports 等,但 Accounts 除外。

以下脚本是我用来调用 api 的 python 脚本。

get_url = 'https://api.xero.com/api.xro/2.0/Accounts'   
response = requests.get(get_url,
                        headers = {
                            'Authorization': 'Bearer ' + access_token,
                            'Xero-tenant-id': xero_tenant_id,
                            'Accept': 'application/json'
                        })
json_response = response.json()
print(json_response)

但这会引发以下错误:

{'Type': None, 'Title': 'Unauthorized', 'Status': 401, 'Detail': 'AuthorizationUnsuccessful', 'Instance': '3c1649ef-6eed-4e64-8503-04fc99481db2', 'Extensions': {}}

谁能告诉我为什么会这样?为什么只是帐户?

4

1 回答 1

1

你能分享你要求的范围吗?https://developer.xero.com/documentation/oauth2/scopes

发票需要accounting.transactions 报告需要accounting.reports.read 帐户需要accounting.settings

于 2020-10-07T22:45:52.273 回答