Patch #11 from https://www.drupal.org/project/commerce_square/issues/2898767 introduced the auto-renewal of the Square OAuth access token through a cron hook.
The intention was:
// OAuth access tokens expire after 30 days. renew a token before it expires.
// Begin attempting to renew on the 29th day.
Sadly the current implementation updates the access token after day 31, leaving the site without working Square Connect for 1 day.
Following Watchdog error is found when using Square on site, or when going to Home » Administration » Store » Configuration » Payment methods » Editing reaction rule "Square" it's shown in the message area:
[HTTP/1.1 401 Unauthorized] {"errors":[{"category":"AUTHENTICATION_ERROR","code":"ACCESS_TOKEN_EXPIRED","detail":"The provided OAuth access token has expired. You must renew the access token via the Renew Access Token endpoint."}]}
Since this only occurs during 1 day after the OAuth access token has expired and after that day the OAuth access token is correctly renewed, this is probably the reason why the reports in the related issue come back every now and then, and can't be reproduced.
Marking this as major since it leaves the Square payment option unusable for 1 day every month.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | commerce_square-Access_Token_renewal_starts_day_too_late-2940651-3.patch | 726 bytes | spokje |
Comments
Comment #2
spokjePatch will be uploaded in the next 1-2 hours.
Comment #3
spokjePatch
Comment #4
spokjeComment #5
spokjeComment #7
mglamanThan you for the logic fix!