Skip to content

Conversation

@n7studios
Copy link
Contributor

Summary

Reduces the likelihood of 401 unauthorized requests being sent to the Kit API by scheduling a WordPress cron event to refresh an expired access token on its expiry.

Presently, the Plugin relies on logic to check if an API request returns a 401 error with the message The access token expired. On lower traffic sites - for example, where there are not many customers subscribing or purchases being sent to Kit - this isn't a reliable method, as a call to the API won't always be triggered.

Testing

  • testCronEventCreatedWhenAccessTokenObtained: Test that the convertkit_refresh_token event is scheduled when OAuth first completes and the Plugin receives access and refresh tokens.
  • testCronEventCreatedWhenTokenRefreshed: Test that the convertkit_refresh_token event is scheduled when the access token is refreshed.

Checklist

@n7studios n7studios self-assigned this Jun 25, 2025
@n7studios n7studios added the bug label Jun 25, 2025
@github-actions
Copy link

WordPress Playground

🚀 Your PR has been built and is ready for testing in WordPress Playground!

Click here to test your changes in WordPress Playground

@n7studios n7studios requested review from a team, corydhmiller and noelherrick and removed request for a team June 26, 2025 02:44
@n7studios n7studios marked this pull request as ready for review June 26, 2025 02:44
@n7studios n7studios merged commit 477a3c4 into main Jun 27, 2025
452 of 485 checks passed
@n7studios n7studios deleted the automatically-refresh-token branch July 12, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants