Closed craigcallen closed 7 months ago
A 401
means "unauthorized", so the first thing to check would be if your GitHub access token is still valid (assuming that it's a private repository). I believe at least some tokens expire automatically, and an expired token could cause updates to stop working without any code changes.
The "Plugin not found" error, on the other hand, would typically mean that the update checker is configured incorrectly, e.g. maybe the file name or slug passed to PUC is wrong. However, that's not the kind of error that would start happening suddenly without any code changes.
The "View details" screen shows an iframe with a URL similar to this:
https://example.com/wp-admin/plugin-install.php?tab=plugin-information&plugin=plugin-slug-here§ion=changelog
Take a look at the iframe URL for your plugin. Does the plugin
query parameter match your plugin? If you're using a custom slug when initializing PUC, does it match that slug?
Finally, an unrelated thing that could cause this error is if PUC is not initialized during that request. Does the plugin only initialize the update checker under certain conditions?
I set my token to never expire, but will take a look at it and test a new key. Will keep you posted on results.
I set my token to never expire, but will take a look at it and test a new key. Will keep you posted on results.
Do I need a different token for each plugin or theme?
I think that's technically not necessary unless you're using fine-grained tokens that are restricted to only having access to specific repositories.
Is there documentation showing access token setup? I currently only have "repo" and all sub selections checked. Should I have more scopes added?
I have a couple of tokens myself, for testing purposes. For the classic token, I have all of the "repo" options enabled and also "workflow", but that one is probably unnecessary. For the fine-grained token, I've given it access to a specific repository and read-only access to "Contents" and "Metadata".
Here is some of my code below - I have a few characters removed the token for security reasons, but is there anything you notice here? I am at a complete loss.
<?php
/*
Plugin Name: My Website Custom Functions
Version: 1.0.2
Description: Custom functions built for Allen Media websites and PWA's.
Author: Craig Allen, Web Designer & Developer
Author URI: https://craigcallen.com
Plugin URI: https://github.com/craigcallen/my-website-functions-plugin/
*/
//require_once(plugin_dir_path(__FILE__) . '/includes/user-last-login.php');
//Plugin Verion update checker via Github
require 'plugin-update-checker/plugin-update-checker.php';
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://github.com/craigcallen/my-website-functions-plugin/',
__FILE__,
'mywebsite-functions'
);
//Set the branch that contains the stable release.
$myUpdateChecker->setBranch('main');
//Optional: If you're using a private repository, specify the access token like this:
$myUpdateChecker->setAuthentication('ghp_tokenkey');
One thing I notice is that you seem to be using an old version of PUC. If it's anything older than 4.9 it's certain to have some GitHub-related bugs, and other 4.x releases also have known issues. I would recommend upgrading to the latest release (currently 5.3).
Noticed that after I sent in the message. Testing again this morning. Appreciate your help.
New errors - At first I was getting an archive error, so downgraded wordpress version to 6.4.2. Now I am getting more errors after updating to newest version:
Could not determine if updates are available for My Website Custom Functions.
I just added you to the repository - would you care to see what I am doing wrong? Doesn't seem like this should be this difficult.
I tried a few tests, and as far as I can tell, it is a bad access token. Try generating a new fine-grained token?
I already tried the above myself, but it appears that I can't generate a token for a repository that I do not own even if I technically have access. So I made a fork and generated a token for that repository. I replaced the repository URL and token in the code, and it works - no other code changes required:
That was it - greatly appreciate your time and assistance on this.
This error just started recently on all of our plugins and themes. They were working perfectly before and no changes in code on our end, but we cannot update anything remotely now. Please advise, thanks in advance for you help.
Also getting an error when I click the 'View details' of the plugin and it says it cannot be found.