Issue obtaining a token

Hi all,

I’m fairly competent at PHP but certainly no expert and OAuth has my head spinning, however I did find some useful information here

but I’m running into a problem. My needs are quite simple, I just want to import invoices from my ecommerce website on a daily basis, either via a cron job or manually, it doesn’t really matter.

Now, using the code example above I am able to complete the first step of getting a code. The issue is exchanging that code for a token. I am getting an error 400 “invalid_grant”.

Not knowing if this was an issue with the sample code I’m using I tried in the Google playground and here I get the same problem. Getting the code is no problem but getting the same “invalid_grant” error when trying to exchange it for a token.

Based on this, I’m guessing an issue on Freeagent side?

Any help would be greatly appreciated. I need to move away from Kashflow who are bloody useless with customer service but I need the ability to import my orders as invoices.

TIA, Elliott