【发布时间】:2020-05-21 14:32:46
【问题描述】:
我将 Xero Api 与 Nodejs 和 xero-node 库一起使用。
我已完成 oAuth 流程并将令牌保存到数据库中。我现在遇到的问题是在尝试从 Xero 获取联系人、帐户或用户的任何内容时,不断收到 403 禁止错误。示例代码如下
我可以毫无问题地让租户满意,但其他任何事情都不起作用。我检查了范围以确保在设置客户端时它们是正确的。
var getStuff = async(tokenSet) => {
await xero.setTokenSet(tokenSet);
const tenants = await xero.updateTenants();
const xeroTenantId = tenants[0].id // {String} Xero identifier for Tenant
const ifModifiedSince = new Date("2020-02-06T12:17:43.202-08:00");
const where = 'IsSubscriber==true'; // {String} Filter by an any element
const order = 'LastName ASC'; // {String} Order by an any element
console.log(tenants);
try {
const response = await xero.accountingApi.getUsers(xeroTenantId, ifModifiedSince, where, order);
console.log(response.body || response.response.statusCode)
}
catch (err) {
/// console.log(err);
console.log(`There was an ERROR! \n Status Code: ${err.response.statusCode}.`);
console.log(`ERROR: \n ${JSON.stringify(err.response.body, null, 2)}`);
}
}
【问题讨论】: