我将 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)}`);
}
Run Code Online (Sandbox Code Playgroud)
}
哪些范围已添加到您正在传递的访问令牌中?您可以在此处解码您的令牌https://jwt.io/
\n\n另外 - 您需要将 \xe2\x80\x98tenant.tenantId\xe2\x80\x99 传递给该函数。我相信tenant.id实际上与从/connections端点返回的连接id相关。
\n\n我的预感是这就是问题所在。也很好奇 \xe2\x80\x99s 是如何工作的,因为 updateTenants() 应该在末尾有空函数调用。这对你有用吗?
\n 归档时间: |
|
查看次数: |
3581 次 |
最近记录: |