Closed guillome2k closed 3 years ago
@guillome2k Can you give some more details about your implementation? The code snippet you provided is not enough for us to help troubleshoot.
https://moneybird.com/oauth/authorize
and doing an API call https://moneybird.com/api/v2/administrations.json
?Hi Dennis, Thanks for your reaction.
I am using OAuth2 with callback for external application, and completely using this code: https://github.com/picqer/moneybird-php-client/tree/master/example With only 1 change i mentioned in my first post, because i can not hard code the administration ID as you do in your example.
And your second point is correct, after authorize i need to wait for 2 seconds to make a call like /administrations.
I just tested on my end, and it looks like it's an issue on Moneybird's side. I got the same error as you got:
Picqer\Financials\Moneybird\Exceptions\ApiException : Error 401: {"error":"token is invalid","symbolic":{"request":"invalid_grant"}}
I then tried with Moneybird's own CURL example, where the exact same happened. Like you said, if you wait for a few seconds before issuing an API call, everything works fine. It looks like Moneybird's backend needs to do some processing after issuing a token, which doesn't happen in time for you requesting some API data.
Would you mind reporting this issue to Moneybird and keeping us posted on the status? Feel free to reference this GitHub issue. Thanks in advance!
I`ll do that. But 1 addition: the Dropbox OAUth2 connection has exact the same problem. Maybe it is an general OAuth2 problem.
What I've seen before, is that the time server of external parties is a few seconds off your own server's time (like when Moneybird's time is 14:01:05 and your time is 14:01:00, then Moneybird's token will not be valid on your system yet). This is just some speculation; it's best to leave it up to Moneybird to get this fixed ;-)
Hi, when i use the example code and a i got this error. After refresh or sleep of at least 2 seconds its all good.
1 little change in the code is:
What is going wrong?