wp-net / WordPressPCL

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application
MIT License
335 stars 131 forks source link

Basic authentication failing, but working use 3rd party tool. #326

Closed richardaubin closed 1 year ago

richardaubin commented 1 year ago

I have created an application password on my administrator's user account. I have secured my endpoint using a 3rd party wordpress plugin.

When I run the following in my app

var uri = "https://url"; var username = "administrator"; var password = "applicationpassword"; var route = "wp/v2/customendpoint";

var client= new WordPressClient(uri); client.Auth.UserBasicAuth(username, password);

When I execute this, I get an authentication error:

client.CustomRequest.GetAsync<List>(route);

But if I test the api/username/password through https://reqbin.com/ it passes the authentication check.

This tells me that I'm not using this library correctly or there's something wrong with how it's sending the username/password.

richardaubin commented 1 year ago

Found the problem, on my end... needed to change to (route, false, true) to useAuth.