[Mostly Resolved] WordPress Plugin 204 & 401 Errors; Post Sync Issues

Latest build is generating these errors:

0 days ago

Response code: 401 Response :{"error": "invalid_grant"}

0 days ago

Response code: 401 Response :{"errors":[{"code":1,"code_name":"Unauthorized","detail":"The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.","id":"3c41aab3-180f-4068-b572-31ab890ce9db","status":"401","title":"Unauthorized"}]}

0.01 days ago

Response code: 204 Response :

@codebard Tried reconnecting to resole to no avail. Reinstalled again just now and reconnected, got a 204 Response again and seeing if I get another 401 in a few minutes again.

Update: For some reason itā€™s not pulling in my latest post so not sure whatā€™s making it return 204 since that post isnā€™t on the WP posts page at all yet. Shouldnā€™t be anything stopping it, I donā€™t have caching set up on that domain/website, and I donā€™t have post-upload image processing set on the Lawyerā€™d page either, hmm.

Update 2:
I just received a WordPress alert that the Patreon plugin is causing a problem with the WP cron as follows:

Error Details
=============
An error of type E_ERROR was caused in line 313 of the file /removed-for-privacy/[lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php](http://lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php). Error message: Uncaught ArgumentCountError: Too few arguments to function Patreon_Content_Sync::check_replace_patreon_images_with_local_images(), 2 passed in /home/removed-for-privacy/[lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php](http://lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php) on line 171 and exactly 3 expected in /[removed-for-privacy]/[lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php:313](http://lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php:313)
Stack trace:
#0 /removed-for-privacy/[lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php(171)](http://lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php(171)): Patreon_Content_Sync->check_replace_patreon_images_with_local_images('While things...', Array)
#1 /removed-for-privacy/[lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php(129)](http://lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php(129)): Patreon_Content_Sync->add_new_patreon_post(Array)
#2 /removed-for-privacy/[lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php(87)](http://lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_content_sync.php(87)): Patreon_Content_Sync->add_update_patreon_post(Array)
#3 /removed-for-privacy/[lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_wordpress.php(2780)](http://lawyerdcomic.com/wp-content/plugins/patreon-connect/classes/patreon_wordpress.php(2780))

Update 3: Still same error, nothing syncing, reinstalling fresh and re-doing the token did not help and I am continuing to receive these errors as well:

**0.07 days ago**

Response code: 401 Response :{"error": "invalid_grant"}

**0.07 days ago**

Response code: 401 Response :{"errors":[{"code":1,"code_name":"Unauthorized","detail":"The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.","id":"bdc98f38-d0da-47a5-9123-1886faaf7794","status":"401","title":"Unauthorized"}]}

I just checked token settings compared to the plugin and everything checked out, though I just realized the token that the wizard auto-generates does not set app category on the client which might be where the 401 is coming from! I manually added ā€œPatron Benefitsā€ under the clientā€™s settings. I waited for sync to try to go through and it returned a 401 again as above.

This is a bit worrysome now as Patreon is dropping API support. I hope youā€™re not getting screwed on managing future development due to this codebard :frowning:

That error may be due to using the plugin with a v1 client with post sync. To upgrade to v2, you can try the below guide:

Just try it out and let me know if it clears these issues.

I should have noted, Iā€™ve been using the v2 client already and getting this error. This problem only occurred after updating to the latest plugin, even after a fresh install and changing the client twice (both v2, one time using the wizard, one time manually to see if the automated one was causing issues.) Nothingā€™s worked to resolve it so far though. @codebard

Can you try a totally new post import by starting an import as of today.

0 days ago

Response code: 401 Response :{ā€œerrorā€: ā€œinvalid_grantā€}

0 days ago

Response code: 401 Response :{ā€œerrorsā€:[{ā€œcodeā€:1,ā€œcode_nameā€:ā€œUnauthorizedā€,ā€œdetailā€:ā€œThe server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesnā€™t understand how to supply the credentials required.ā€,ā€œidā€:ā€œbdbaa616-f4a6-42ba-96fe-af2b17480bd3ā€,ā€œstatusā€:ā€œ401ā€,ā€œtitleā€:ā€œUnauthorizedā€}]}

I also got another email again citing the same line (313) for Error message: Uncaught ArgumentCountError: Too few arguments to function from plugins/patreon-connect/classes/patreon_content_sync.php.

@codebard Resolved. Following this userā€™s post in the plugin editor to the code resolved my issue entirely with sync not happening, though itā€™s not importing the right default image now. It still is showing those 401 unauthorized issues in health check but it seems to be allowing post sync anyway.

It looks like itā€™s having an issue if the file names are the same from the upload to Patreon. For example, I have 2 posts that use different ā€œ1.pngā€ images. It looks like the post sync is using the same ā€œ1.pngā€ for both, because the earlier postā€™s 1.png replaced the 1.png in the newer postā€™s body content.

Indeed that is a good find and it would address the problematic images. You can use that fix for the time being. I am going to soon make a change to the handling of featured image setting and provide a package to both of you. That will allow separate processing of featured image without disturbing the post import process or having to re-update the post after insertion to get its images.

1 Like

Here is an updated branch.

This should fix those issues. Just give it a try and let me know.

1 Like

If you would prefer, here is a zipped package from dropbox which you can directly install after deleting your existing Patreon Wordpress:

1 Like

Great! :slight_smile: Give me a few minutes here Iā€™ll get this set up and let you know the results.

@codebard hereā€™s the current status:

1. Still getting the following errors; however, they donā€™t seem to be causing any issues with the plugin/content itself:

**0 days ago**

Response code: 401 Response :{"error": "invalid_grant"}

**0 days ago**

Response code: 401 Response :{"errors":[{"code":1,"code_name":"Unauthorized","detail":"The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.","id":"67e07b40-1a81-4f0e-9173-4cb9ceab0065","status":"401","title":"Unauthorized"}]}

**0 days ago**

Response code: 204 Response :

2. I also noticed that even on Patron-only locked text posts with images where the internal images are supposed to be content-locked, the first image is pulled and made publicly visible as the featured image rather than a different default or empty featured image.

I figure in the meantime I can just ensure that the header post image or first image of a text post is something Iā€™m comfortable being made public on the WordPress though so Iā€™m not too worried about that in the short-term. Would be a good FYI for creators though!

Otherwise, it looks like everything else is back to normal for post sync (including fixing the weird ā€œwrong imageā€ I had as well as properly triggering my social media post relays with Jetpack.) Now if I can only figure out why IFTTT is having issues turning content into embeds over Discord webhooks nextā€¦ :laughing:

Image locking situation is currently expected since the image lock cannot be directly supported if its not set to on at the WP site.

The auth errors are a bit weird. They are likely happening to various users.

1 Like

@codebard just discovered something odd happening. It looks like (some) posts are regularly re-syncing, at least once? I use Jetpack to automatically relay post URL and teaser text to Twitter and Facebook and just noticed this is happening:

My only guess is that something in the plugin is causing synced posts to re-post at a set interval, likely due to the re-sync upon update/edit feature. If so, we might need a conditional that limits posts from updating only if thereā€™s changes.

Regular re-sync should not happen. Does a post import seem to be going on when you check the bottom section at Patreon Settings page?

Yeah, itā€™s got the There is an ongoing post import. green text. It hasnā€™t happened again though. Iā€™ll see what happens next time I schedule a new post. Maybe it was something else that got delayed along the way with WordPress and Jetpack or IFTTT.

Then the posts are being updated from Patreon during this process? What happens if you delete a test post? Does it get repopulated from Patreon?

There is a new format of post import is available - it now manually imports posts. Check this out and let me know how it works out.

You can deactivate/delete your existing Patreon WordPress and upload/activate the above package.

At the ā€˜Star a post importā€™ section of Patreon Settings, you can now manually import posts. When you start a post import, the section will transform into an ā€˜Ongoing post importā€™ state, allowing you to import the next batch of posts by clicking ā€˜Import next batchā€™ button which will appear. You can do this every 10 seconds.

The status messages will guide you through the import.

If youā€™d rather get it from github:

You can now manually import your posts with 1.6.1. Just upgrade from your WP admin and you are set.