Closed arivazhaganark closed 3 years ago
When newly authorized, it should last for 24 hours. The endOfLife returned from the API should be the seconds from when it was authorized until it expires. The API doesn't return a Unix timestamp for when it expires. Thus if you're going to rely on such information, need to also store the timestamp it's relative to.
In my JavaScript console when I run:
(new Date(1612436406*1000)).toUTCString()
I see
Thu, 04 Feb 2021 11:00:06 GMT
In order to reach a date like 2072, this would look like the same leap from the 1970 Epoch. Thus it looks like you're adding it twice:
(new Date(1612436406*2*1000)).toUTCString()
Thu, 10 Mar 2072 22:00:12 GMT
This value is within about 7 hours of the date you posted.
Looks like it's getting added twice somehow. Should investigate what's going on each step of the way until you understand what your code is doing.
To avoid these kind of issues, I wouldn't rely entirely on the end of life token.. I'd still have a cronjob to refresh the token. At least that's what I do. I believe the system performs better with such a cronjob. Doing that sort of extra work when there's an actual user request you're handling just increases the chance of network issues and adds to the wait, etc. I don't rely entirely on cronjobs either. I currently use a mix of the end of life token and a cronjob to keep the database tokens fresh.
But yeah, looks like you're adding something twice. Should definitely look what's going on before getting into cronjobs.
Ah yes, i was fixed that. My Token was serialize twice
When authorise Infusionsoft via OAuth2, the response token expire with in few hours
But debug the \Infusionsoft\Token Object,
Even after expired (2021-02-04 06:00:06) the method
$this->isTokenExpired()
still comes TRUESo the API returns 401 UnAuthorized