-
Notifications
You must be signed in to change notification settings - Fork 8
Delete Invalid Access Tokens from Settings #952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9199aa2
Settings: Delete Invalid Access Tokens
n7studios 1d479ac
Update hooks
n7studios 0fefe4a
Added integration tests
n7studios 5cc94be
Notices: Persist authorization notice based on token success/error hooks
n7studios aafda83
Tests: Reset persistent notices between tests
n7studios 357425d
Move Admin_Notices class to global
n7studios df2f6c3
Remove `convertkit_api_refresh_token_error` hook
n7studios f59ae9c
Merge branch 'main' into delete-invalid-access-token-from-settings
n7studios 4a183a3
Remove redundant test
n7studios File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the server returns a 5xx error? Would we just delete the credentials? What about a 429 rate limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe_delete_credentialsis only called when the Kit WordPress Libraries fires specific hooks:convertkit_api_refresh_token_error: An attempt to refresh an expired access token failed: https://github.com/Kit/convertkit-wordpress-libraries/blob/add-hooks-on-request-error/src/class-convertkit-api-v4.php#L414-L440convertkit_api_access_token_invalid: An invalid access token was used (note, this differs from an expired access token being used): https://github.com/Kit/convertkit-wordpress-libraries/blob/add-hooks-on-request-error/src/class-convertkit-api-v4.php#L1463-L1519Code in this PR that checks for these hooks:
https://github.com/Kit/convertkit-wordpress/blob/delete-invalid-access-token-from-settings/includes/class-convertkit-settings.php#L52-L55
Other errors, such as a 429 or 5xx, won't result in tokens being deleted from the Plugin's settings. Libraries return a WP_Error, which the Plugin then handles accordingly.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we get a non-401 from the refresh itself, wouldn't that cause the tokens to be deleted?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. Removed
convertkit_api_refresh_token_errorhook, ensuring access token only deleted if the API class uses an invalid access token, not an expired one.