Invalid Client Error

If you're getting the following error when authenticating with the Xero API:

{     "error": "invalid_client" }

according to the Xero OAuth 2.0 Troubleshooting Guide you will get this error if the client_id or client_secret you pass in are incorrect. They recommend that you make sure you have the correct credentials for your app and to double check your client id in My Apps and try generating a new secret if required.

Another cause of this error in fmAccounting Link (Xero Edition) v1 is the version of the BaseElements plugin that you have installed. A number of the plugin functions that we use when making requests to the Xero API were removed in v4.2 and later of the plugin which causes the OAuth 2.0 authentication process to fail leading to the invalid_client error message. If you are using v4.2 or later of the BaseElements plugin you will find <Function Missing> references in the following scripts:

  • Xero Authentication - OAuth 2.0 Complete
  • Xero Authentication - OAuth 2.0 Refresh Access Token

like in the following screenshots:

The <Function Missing> is a reference to the BE_Base64_Encode function that was removed in v4.2 of the plugin (this can also appear as BE_Base64_Encode_Deprecated). There's a couple of options to resolve this:

1. use the native Base64EncodeRFC function if you're using FileMaker Pro v16 or later. The equivalent to the plugin function above would be:

Base64EncodeRFC ( 3548 ; Interface::ClientID & ":" & Interface::ClientSecret )

You can update this calculation for the fmAccounting Link (Xero Edition) Single Organisation.fmp12 file as follows:

BE_HTTP_SetCustomHeader ( "Authorization" ; "Basic " & Base64EncodeRFC ( 3548 ; Interface::ClientID & ":" & Interface::ClientSecret ) )

You can update this calculation for the fmAccounting Link (Xero Edition) Multiple Organisations.fmp12 file as follows:

BE_HTTP_SetCustomHeader ( "Authorization" ; "Basic " & Base64EncodeRFC ( 3548 ; Organisations::ClientID & ":" & Organisations::ClientSecret ) )

2. you can also download and install a previous version of the plugin (prior to v4.2) that includes the required functions. Here are the links to downloading v4.1.4 of the plugin for Mac and Windows (64bit only):

If you're using an Apple computer with the M1 processor and FileMaker Pro v19.3 or later which includes Apple silicon support you will have to force FileMaker Pro to run as an Intel app instead of a native M1 app. This article has the details for changing an app to run using Rosetta on an M1 Mac.
3. you can also upgrade to fmAccounting Link (Xero Edition) v2 which removes the plugin dependency and uses all native FileMaker scripts and functions for communicating with the Xero API. 

Still need help? Contact Us Contact Us