Services Plugins FAQs

Xero accounting plugin - expired token issue

Hi

I’m currently trying to get the Xero accounting plugin working but am having some issues. I did try to follow the documentation but that doesn’t seem to quite work or match your demo app in the way things are done.

I believe I have everything setup correctly for the actual integration as I’m able to connect and authenticate with Xero and get back the user info (id, email, give name, family name etc) ok.

But if I then try and make any calls (to get invoices for example) I get an error message ref the token already being expired as below.

What would you suggest as a way forward?

Thanks

Richard

Hi @richard8, thanks for your message.
I’ve passed described issue to the developer team for research. Once any results will become available, I will let you know asap.

Thank you for understanding :pray:

Regards,

1 Like

Thanks! I’d really appreciate a quick response (but fully understand everyone else probably wants the same!) as this issue is currently holding up a project :grimacing:

I’m sure it must be something I’m doing/not doing though as your demo (with different database architecture but the same stored info) still works ok.

Hi @richard8, sorry for no useful information shared so far :pray:
The developer team is checking internally what might be the reason for reported issue so I also wait for the results. In case any additional details will be required, I will let you know.

Regards,

Thanks! As your demo App is working I think it must be something I am doing even though I thought it was setup correctly and is authenticating initially. It probably needs one of your team to look at my App to see the issue.

Hi @richard8, thanks for your reply.
Please add our Support Team email to the list of collaborators to your application and provide me (in a DM) a link to your application, with an indication on which page the case is set and how to get the error as mentioned above. Please also check if within your Xero account are enough dummy data to be used for data calls (for example - to display Invoices, at least a few of them should be created).

To add our Support Team as a collaborator, you need to do the following steps in the Bubble Editor:

Settings > Collaboration > Add email support@zeroqode.com

Note: avoid the warning message regarding the plan, as we are an agency and you can easily add us to your collaborators.

Looking forward to your reply.

Regards,

Thanks @Serg , I’ve just DM’d you with the info and demo video, and added you as a collaborator.

Hi @richard8, thanks for your patience and provided access.

Our developer team checked your setup and would like to share the following feedback:

Within your app, when you want to refresh the token, the workflow sends a list of refresh tokens. In our demo, we send Refresh Token from the first element was found. In your case, the user sends a list of refresh tokens from all Users.

There are 2 ways to fix it:

  1. After authentication on Xero, save the email from Xero on state.


    In this case, you can do “Search for Users” with email constraint and get “:first items’s xero refresh token” from the obtained user in the “Refresh Token” action.

  2. After authentication on Xero, you can add the “Log in” action with an email obtained from Xero authentication. In this case, you can use “Current user xero refresh token” in “Refresh Token” action.

Hope this hint will help. If there will be anything else that I can help with about our plugin, please let me know.

Regards,

Hi

Thanks for looking into this for me. Unfortunately, the multiple token issue was created when I modified the existing issue whilst clutching at straws! I’ve put the code back to how it was originally which is the issue with an expired token (screenshot of error message below).

If I understand it correctly after a quick look, the login suggestion won’t work for me either as the email address of the Bubble user may not match the email address of the Xero user (in my test case, it definitely doesn’t).

Hi @richard8, thanks for your reply.

We’ve asked the developer team to check this moment once again. As soon as there will be any related feedback, I will let you know :pray:

Regards,

@richard8
As far as we understood, the problem is in static credentials that the user sends in the call. In our demo, we are using dynamic values.

It is necessary to use the last obtained access token from “Get Xero Token From URL Oauth 2.0” or from “Refresh Token” actions.


We recommend saving the access token in the database for the Current User, then getting it.

For example, in workflow on page load, add Login to bubble action (after step 3, getting the mail from Xero).

Regards,

Thanks for all your help and pointers with this!

I managed to get things working yesterday and now have data pulling in from Xero ok :+1:

Thanks again for your help :raised_hands:

2 Likes

Hi @richard8, you’re welcome, and thanks for letting me know that everything works well now :hugs:

If you like our plugin, we would be grateful if you can rate it by going to the Plugins tab in Bubble editor. Find the plugin by name and it gives it as many stars as it deserves

The more feedback we get, the more motivated we are to make things better in Bubble.

Have a great day ahead!

Regards,

1 Like

Thanks @Serg

I do have another question now :see_no_evil: :joy:

This time regarding the dates and formats. For example, if I do a “get invoices” then I’m able to get and display the invoice data in a (filtered) repeating group which is great.

However, the Plugin/Xero API returns the invoice date in a couple of formats (e.g. Either “/Date(1670716800000+0000)/” or “2022-12-11T00:00:00”) but neither of these can be used as a date and formatted as such within Bubble as they come back as type “text”.

Within my project, I want to be able to both display the dates UK format (e.g. “11/22/22”) and also use the field to calculate differences between dates and the current date (for overdue invoices etc). I can’t do that with either of the above fields as their type is text rather than date.

Any ideas for the best solution?

@richard8, thanks for your question.

I’ve passed this to the developer team for research. Once any feedback will become available, I will let you know asap.

Thank you for understanding.

Regards,

Hi @Serg

I found a solution for this using the “toolbox” plugin and using expressions within it to convert to dates.

However, I’ve found a big limitation with the plugin for the project I’m working on. When I initially looked, I saw the big list of calls and assumed it included all the available Xero API’s. I’ve now discovered that it doesn’t include a couple of calls that are fundamental to this project :grimacing:

One call is Xero Get Contacts and another is the ability to create an invoice with the Xero Post Invoices calls.

Is it possible for you to add these to the plugin? And if so, what would be the process and timeline for doing so?

Thanks

Richard

Hi @richard8, sorry for the delayed reply.

We’ve pushed an update that changed sourced API values as it follows:

  • datestring - as text
    image
  • date as date
    image

So it would be simpler to set up the invoice date. For that, please update your plugin to the last version (1.7.0: Changed data type to date in all API Calls & added 3 new Calls) and give it a try.

Lem me ask the developer team for feedback. Once any news will become available, I will let you know asap.

Thank you for understanding.
Regards,

1 Like

Hi @Serg

Thanks so much for the date format update. I’ve just modified our project to use this instead of what I’d had to do (using the Toolbox plugin and expressions) and this works great :raised_hands:

After the work that’s already gone into this project using your plugin I’d really like to continue using it so if you could let me know ref adding the additional calls asap then it would be really appreciated. Because of timeframes (my client and I had hoped we’d have the whole project complete by now :grimacing:) then I’m having to look at talking directly to the Xero API to get things complete but I’d much prefer to use your plugin.

Thanks again

Richard

Hi @Serg

I just noticed that you’d done an update to add the missing API calls I asked about. Thanks SO much for this :raised_hands:

However, I just tried to use the “get contacts” and it’s throwing an authorization error despite being logged in and authorised (other calls like get invoices are still ok). This is the same issue I was seeing when I was using your plugin to authenticate and then trying to make the API calls directly myself so hopefully I think I know what the problem is so can help fix it. I think you just need to add the correct scopes to the authentication as these extra calls require additional scope/permissions. I believe the additional scopes you need to add are “accounting.contacts” and “accounting.transactions”. Hope this helps!

Thanks again

Richard

1 Like

Hi @richard8, sorry for the delayed reply.
Indeed, we pushed a plugin update (Version 1.8.0: Added Get All Contacts, Create Invoice, Deleted Tracking Categories calls & updated “Create” api calls.) which added the required API calls.

I’ll pass this on to the developer team, so they will check if any changes should be applied. Once any feedback becomes available, I will let you know asap.

Thank you for understanding :pray:

Regards,