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):