0

I'm in the process of updating our app from from oauth 1 to 2. Entire flow works well - I can migrate and save the tokens and access the APIs. However, there is a problem once the original token expires and it gets refreshed. After refreshing, the call to updateTenants does not return any active connections.

My pseudocode is below:

  const tokenSet = await getTokenSet(); // Returns saved token set from DB. Assume token is expired!!
  const client = new XeroClient(...);
  client.setTokenSet(tokenSet);

  const newToken = await client.refreshToken();
  await saveTokenSet(newToken); // Save to DB

  const token = client.readTokenSet();
  console.log(token); // Does return my NEW active token set
  const tenants = await client.updateTenants(false);
  console.log(tenants.body); // This returns an array of length 0

Not clear why the results from updateTenants is empty. I was able to verify this by calling the GET https://api.xero.com/connections endpoint manually with one of the refreshed tokens and also see an empty array in the body.

Any ideas?

Billy Johnson
  • 461
  • 3
  • 8

1 Answers1

0

I played around with our xero-node-oauth2-app to see if I could recreate this. Here's what I found:

If I connected to my Xero org to obtain valid tokens and then disconnected via the Xero connected apps dashboard and then refreshed my tokens triggering updateTenants the connections endpoint returns an empty array and status code 200. In other words, it's a successful call but Xero doesn't see that the user has authorized your integration to interact with any of their orgs/tenants.

Are you able to verify if your integration is still listed in the connected apps list under settings?

https://community.xero.com/developer/discussion/127403806

Rett Behrens
  • 181
  • 1