[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: