Login for Wordpress Rest API

I am using the Wordpress Rest API for my WinJS Universalapplication and would like to somehow log in to my users before allowing them to view the products that I also receive from the API.

I tried something like this

var settings = { "async": true, "crossDomain": true, "url": "http://example.com/wp-json/users/me", "method": "GET", "headers": { "authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ==", "cache-control": "no-cache" } } $.ajax(settings).done(function(response) { console.log(response); }); 

But I get

 DENIED - The requested resource requires user authentication. (XHR): GET - http://example.com/wp-json/users/me 

I also tried using Postman and got it back

 [{"code":"json_not_logged_in","message":"You are not currently logged in."}] 

I'm not sure what I'm doing wrong, as I'm trying to log in with a username and password combination that is in the Users list in Wordpress.

UPDATE:

After installing the basic authentication module, I can now get it to work, but now when I enter the wrong username or password, Windows 10 jumps and opens its own registration form instead of letting me handle it.

Now I need to figure out how to suppress this behavior.

+5
source share
1 answer

Glad you understood that. I recommend that you use the Application Passwords plugin instead of basic authentication, as the latter is only for testing / dev and not so safe for production!

0
source

All Articles