Changes to Xero Token Expiry in v2.1.1

We've made some changes to how the Xero Token expiration refresh is calculated and checked in v2.1.1 of fmAccounting Link, as well as some changes to the fmAccounting Link Single Organisation File to better support multiple user access.

Here's a summary of the changes:

fmAccounting Link (Xero Edition) Multiple Organisations File

We've changed the formula we use calculate the OAuth 2.0 Token expiry timestamp to better handle users in multiple timezones. Previously were were using:

Get ( CurrentTimestamp )  + $expiresIn

to set the value for the AccessTokenExpires timestamp field. This uses the user's local system time to generate the value for the Get ( CurrentTimestamp ) function when performed from a FileMaker client (e.g. FileMaker Pro, FileMaker Go) or the FileMaker Server system time when running as a FileMaker Server script . If all your users and the FileMaker Server were located in the same timezone this didn't present any issues, but if you have users spread across multiple timezones this could cause issues with tokens failing to be refreshed correctly. We've simply switched to using the Get (CurrentHostTimestamp) function instead which returns the host's current date and time according to the system clock, which will be the same value for all users regardless of where they are located:

Get (CurrentHostTimestamp) + $expiresIn

We've made a similar change when checking whether the Access Token has expired - previously, for example, we were using:

Organisations::AccessTokenExpires < Get ( CurrentTimestamp )

We've changed this to also use the Get ( CurrentHostTimestamp ) function so this has become:

Organisations::AccessTokenExpires < Get ( CurrentHostTimestamp )

N.B. in the FileMaker Cloud products the Get ( CurrentHostTimestamp ) function returns the date and time in Coordinated Universal Time (UTC) so don't panic if the Access Token expiry timestamp has a value for a date/time earlier than your current local time.

fmAccounting Link (Xero Edition) Single Organisation File

Our initial method of using FileMaker global variables to store the Xero Token, Expiry Timestamp, Refresh Token and Tenant ID is not the best method for handling multiple users accessing the fmAccounting Link (Xero Edition) solution at the same time and making requests to the Xero API independently of each other. We've decided to remove these completely as they are not reliable enough and use the same method as we do in the Multiple Organisations file where we simply reference the fields directly. We've removed all references to the following global variables:

  • $$xeroToken
  • $$xeroTokenExpires
  • $$refreshToken
  • $$tenantID

and replaced them with references to the fields that they were using to create the value for these global variables. This involves updating all the cURL options, for example changing this line from:

" --header " & Quote ( "Authorization: Bearer " & $$xeroToken )


" --header " & Quote ( "Authorization: Bearer " & Interface::XeroAccessToken )

We've also made the same changes as above for calculating the Access Token expiry timestamp and when checking whether the Access Token has expired. For example we've replaced this calculation for checking if the Access Token has expired:

GetAsTimestamp ( $$xeroTokenExpires ) < Get ( CurrentTimestamp )

with this version:

Interface::AccessTokenExpires  < Get ( CurrentHostTimestamp )

Still need help? Contact Us Contact Us