Skip to content

WordPress REST API Basic Authorization not working #783

Closed Answered by fairking
fairking asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, looks like something broken in the WooCommerce.NET API Client itself.

My fix was to set the version to V3 as a workaround:

var wp_api = new WooCommerceNET.RestAPI("https://my-site/wp-json/wp/v2/", "admin", "xxxx xxxx xxxx xxxx xxxx xxxx");

// Fix the version number, so we can still use Basic Authentication in Wordpress API
wp_api.GetType()
    .GetProperty(nameof(wp_api.Version), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
    .SetValue(wp_api, WooCommerceNET.APIVersion.Version3);

After that the API started working as expected. Thanks guys for the package 👍

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fairking
Comment options

Answer selected by fairking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant