Iva*_*čić 5 ajax rest wordpress authorization
我在WinJS Universalapplication上使用Wordpress Rest API,并希望以某种方式登录我的用户,然后让他们浏览我从API获得的产品.
我尝试过这样的事情
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);
});
Run Code Online (Sandbox Code Playgroud)
但我明白了
DENIED - The requested resource requires user authentication. (XHR): GET - http://example.com/wp-json/users/me
Run Code Online (Sandbox Code Playgroud)
我也尝试使用Postman并将其取回
[{"code":"json_not_logged_in","message":"You are not currently logged in."}]
Run Code Online (Sandbox Code Playgroud)
我不确定我做错了什么,因为我尝试使用Wordpress中的用户列表中的用户名/密码组合登录.
更新:
安装后基本认证插件我现在能够得到它的工作,但现在当我输入错误的用户名或密码的Windows 10的跳跃,并打开自己的登录表单,而不是让我来处理吧.
我现在必须弄清楚如何压制这种行为
| 归档时间: |
|
| 查看次数: |
1044 次 |
| 最近记录: |