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.

Comments

Spokje created an issue. See original summary.

spokje’s picture

Patch will be uploaded in the next 1-2 hours.

spokje’s picture

spokje’s picture

Status: Active » Needs review
spokje’s picture

Assigned: spokje » Unassigned

  • mglaman committed 7cead85 on 7.x-1.x authored by Spokje
    Issue #2940651 by Spokje: Access Token renewal starts day too late
    
mglaman’s picture

Status: Needs review » Fixed

Than you for the logic fix!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.