WordPress REST API rest_user_cannot_view
我正在尝试使用 Wordpress REST API 获取特定用户的详细信息。我确信我使用管理员凭据来获取详细信息。
但我不断收到以下回复,
{
message: "Sorry, you’re not allowed to list users",
code: "rest_user_cannot_view"
}
我仔细检查了管理员的凭据。管理员有权获取用户详细信息。 尝试使用此解决方案,https://stackoverflow.com/a/36499422 但这没有用。
I'm trying to get details of specific users using Wordpress REST API. I'm sure that I use admin credential to get the details.
But I keep getting the following response,
{
message: "Sorry, you’re not allowed to list users",
code: "rest_user_cannot_view"
}
I double-checked the credentials are of admin's. And admin has access to get user details.
Tried using this solution, https://stackoverflow.com/a/36499422
But it didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过的答案包含您需要的一切。
但那里有一些混乱。所以我又在这里回答一下。
默认情况下,Wordpress 不允许基本身份验证。在此处了解有关基本身份验证的更多信息 https://en.wikipedia.org/wiki/Basic_access_authentication
您需要通过安装启用基本身份验证的插件来启用此功能。
启用它还不够。您的服务器可能不会侦听“Authorization”标头。标头不会从请求传递到其余 api。
您需要通过修改该答案中提到的
.htaccess
来启用它。例如,您可能已经启用了
RewriteEngine On
,如果是这样,请保留该行,否则请包含The answer you tried contains everything that you need.
But there is a bit of confusion going there. So I'm answering here again.
By default, Wordpress doesn't allow Basic Authentication. Read more about Basic Auth here https://en.wikipedia.org/wiki/Basic_access_authentication
So you need enable this by installing a plugin which enables Basic Auth.
Enabling that isn't enough. Your server may not listen for "Authorization" header. The header isn't getting passed to the rest api from the request.
You need to enable that by modifying
.htaccess
as mentioned in that answer. Like,You may already have
RewriteEngine On
, if so leave that line, include otherwise