Closed japaveh closed 2 years ago
@japaveh managed to get this working?
@luukskeur Yes, and I already planned to share the solution here so your head-up triggered this :)
The solution I implemented is by storing the refresh token you get from Twinfield, as this token is valid for a very long time (20 years or so) but I also included code to fetch a new refresh token. I store this refresh token in an include file together with the Twinfield ClientId and secret
I created a class: TwinfieldAdapter (gist) which handles all the communcation to Twinfield using PHPTwinfield and standard Guzzle calls
The process is as follows:
TwinfieldAdapter->getTwinfieldAuthentication()
which uses the refresh token to request a new access token etc.Of course this solution is open for improvements
Nice, thanks for the reply! I hope it helps others.
In the meantime I got it working as well following this example: https://github.com/iranl/twinfield/blob/extend-all/examples/Authorization.php
Storing and using the refreshtoken server-side is the solution, the docs weren't that clear 😅
And, could you close the issue? @japaveh
Hi all
I use this module to do server side requests to Twinfield to check payment status and to send invoices via the API to Twinfield. This works without any issue using the old username password but this method will be invalidated tomorrow.
I am trying to implement the oAuth2 method but I cannot get this working without without any user interaction via the browser. This is obviously a requirement for only server-side interaction
I tried to use the password grant via
But then I get
unauthorized_client
as responseAny tips to get this working?