不能使用WP REST API 2.0插件使用基本身份验证验证 [英] Can't authenticate with basic authentication using WP REST API 2.0 plugin

查看:379
本文介绍了不能使用WP REST API 2.0插件使用基本身份验证验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有基本身份验证的问题。

I'm having an issue with basic authentication.

试图发送一个GET请求使用以下URL邮差(铬插件):
的http:// _ MY_WEBSITE_URL_ / WP-JSON / WP / V2 /用户/ 3

Trying to send a GET request with Postman (chrome plugin) using the following url: http://_MY_WEBSITE_URL_/wp-json/wp/v2/users/3

用户名和密码字段充满了该网站的管理员用户凭据。

The username and the password field is filled with the site's admin user credentials.

错误我得到:

{
    "code": "rest_user_cannot_view",
    "message": "Sorry, you cannot view this resource.",
    "data": {
        "status": 401
    }
}

我尝试使用wp_remote_request从另一个网站的基本身份验证,并与卷曲过,但结果每次都一样。

I tried the basic authentication using wp_remote_request from another website, and with CURL too, but the results are the same every time.

id为3的用户存在,我已经检查了。如果我要列出所有的用户,我只得到那些谁拥有的职位创造。

The user with id 3 exists, I have checked it. If I want to list all of the users, I get only those who have posts created.

我已经激活了所需的插件: WP REST API JSON基本身份验证

I have activated the required plugins: WP REST API, JSON Basic Authentication.

我的话preSS版本: 4.4.2

My wordpress version: 4.4.2

推荐答案

最后,我想出了解决方案。我不得不手动添加一些新的选项,我的的.htaccess 文件,插件并没有做到这一点。

Finally, I figured out the solution. I had to add some new options manually to my .htaccess file, the plugin didn't make it.

在code:

# BEGIN WP BASIC Auth
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /PluginTest/
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
# END WP BASIC Auth

这篇关于不能使用WP REST API 2.0插件使用基本身份验证验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆