【问题标题】:Cant disconnect from xero using xero.disconnect无法使用 xero.disconnect 断开与 xero 的连接
【发布时间】:2020-05-18 08:23:46
【问题描述】:

我使用 AdonisJs 作为我的节点框架,xeroclient 配置完美运行,我可以提取我需要的细节。

我只是无法断开连接,正如我在他们的 sample app 中看到的那样,我们只需调用 xero.disconnect,但我收到错误 xero.disconnect is not a function

我使用的是 xero-node npm 包

const xeroNode = require('xero-node')

const xero = new xeroNode.XeroClient({
  clientId: Config.get('xero.client_id'),
  clientSecret: Config.get('xero.client_secret'),
  redirectUris: [Config.get('xero.redirectUri')],
  scopes: Config.get('xero.scopes').split(" ")
})

async disconnect ({ response, session }) {
   ...
   await xero.disconnect(xero.tenantIds[0])
   ...
}

【问题讨论】:

    标签: node.js xero-api


    【解决方案1】:

    唯一看起来不正确的是您传递给函数的参数。这实际上应该是连接对象的 ID 而不是tenantId 本身:await xero.disconnect(xero.tenants[0].id)

    但除此之外,您能否详细说明您正在使用的软件包版本?我只是模仿了有关您如何导入和设置客户端的所有内容,因此尚不清楚为什么断开连接功能不可用。请确保您使用的是最新版本 4.6.0 - 在我从 /callback 流程成功取回访问令牌后,以下内容才对我有用。

    设置:

    const xeroNode = require('xero-node')
    
    const xero = new xeroNode.XeroClient({
        clientId: client_id,
        clientSecret: client_secret,
        redirectUris: [redirectUrl],
        scopes: scopes.split(' '),
    });
    

    /连接

    const consentUrl: = await xero.buildConsentUrl();
    

    /回调

    const tokenSet = await xero.apiCallback(returning_url);
    await xero.updateTenants();
    

    /断开连接

    const connection = xero.tenants[0]
    
    await xero.disconnect(connection.id)
    

    如果您可以发布/记录更多信息,可以为您整理!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多