Open slayybelle opened 1 year ago
Hello @slayybelle very interesting find! Thank you. I am guessing the more straight forward solution for this is to not test the expiration time exactly but instead check if it's expiring soon. I will add this to this to my list of improvements and will get it done as soon as i can.
Describe the bug When using an access token near its time of expiration, ltijs will throw this error
HTTPError: Response code 401 (Unauthorized)
Happens intermittently, but due to a recent addition of a cron job which ran hourly I was finally able to track this down.
Happens with calls to getLineItemById, getLineItems; I suppose anything that calls
platform.platformAccessToken
Expected behavior Refresh the access token; perhaps add an almost-empty flag to give some extra time to handle this case
Provider logs See the commented section towards the bottom where I added code to track this condition where the token is within 10s of expiring.
This is from Platform.js:
here is what my logs looks like when a getMembers request fails. Note the time computed is 3599933 which is so close to the 3600000ms (expiration time), but is still treated as not-expired
Screenshots If applicable, add screenshots to help explain your problem.
Ltijs version
NodeJS version
Platform used