radishconcepts / WordPress-GitHub-Plugin-Updater

This class is meant to be used with your Github hosted WordPress plugins. The purpose of the class is to allow your WordPress plugin to be updated whenever you push out a new version of your plugin; similarly to the experience users know and love with the WordPress.org plugin repository.
https://github.com/jkudish/WordPress-GitHub-Plugin-Updater
822 stars 195 forks source link

I'm getting a 400 bad request error when clicking the update button #94

Open Knapton-Wright opened 10 months ago

Knapton-Wright commented 10 months ago

I've implemented this code into my plugin and I've got it successfully checking for a new version. What I'm having trouble with however is the fact that when I click the update button I get this response Update failed: Download failed. Bad Request.

In my plugin I've called your plugin code like this:

function kw_check_plugin_update() {
    if (is_admin()) { // note the use of is_admin() to double check that this is happening in the admin
        $config = array(
            'slug' => plugin_basename(__FILE__), // this is the slug of your plugin
            'proper_folder_name' => 'kw-plugin', // this is the name of the folder your plugin lives in
            'api_url' => 'https://api.github.com/repos/Knapton-Wright/kw-plugin', // the GitHub API url of your GitHub repo
            'raw_url' => 'https://raw.github.com/Knapton-Wright/kw-plugin/master', // the GitHub raw url of your GitHub repo
            'github_url' => 'https://github.com/Knapton-Wright/kw-plugin', // the GitHub url of your GitHub repo
            'zip_url' => 'https://github.com/Knapton-Wright/kw-plugin/zipball/master', // the zip url of the GitHub repo
            'sslverify' => true, // whether WP should check the validity of the SSL cert when getting an update, see https://github.com/jkudish/WordPress-GitHub-Plugin-Updater/issues/2 and https://github.com/jkudish/WordPress-GitHub-Plugin-Updater/issues/4 for details
            'requires' => '6.3.2', // which version of WordPress does your plugin require?
            'tested' => '6.3.2', // which version of WordPress is your plugin tested up to?
            'readme' => 'README.md', // which file to use as the readme for the version number
            'access_token' => get_field( 'kw_licence_key', 'option' ), // Access private repositories by authorizing under Plugins > GitHub Updates when this example plugin is installed
        );
        new WP_GitHub_Updater($config);
    }
}

add_action( 'admin_init', 'kw_check_plugin_update' );

I've noticed that copying and pasting the raw_url into a browser brings up this same 400 error, but not if I indicate which file to look at https://raw.github.com/Knapton-Wright/kw-plugin/master/README.md. I'm under the impression that your code uses this url and just appends the file name and path onto the end to update the files necessary.

Are you able to tell where my error is coming from?