wordpress json api错误,而generate_auth_cookie
问题描述:
我有问题的WordPress的JSON Api当登录用户。目前我使用WordPress 4.5.1版下面列出的插件:wordpress json api错误,而generate_auth_cookie
下面是步骤我遵循:
1)生成随机数
http://example.org/api/get_nonce/?controller=user&method=generate_auth_cookie
下面是回应:
{"status":"ok","controller":"user","method":"generate_auth_cookie","nonce":"4d080ff7b8"}
2)生成验证Cookie的
下面是响应:
{"status":"error","error":"SSL is not enabled. Either use _https_ or provide 'insecure' var as insecure=cool to confirm you want to use http protocol."}
为什么我得到这个错误?
答
看来,JSON API User
和JSON API Auth
插件默认只允许通过https连接。
为了关闭此设置,你应该在请求发送一个额外的参数:
insecure=cool
所以请尝试以下要求:
http://example.org/api/user/generate_auth_cookie/?nonce=+4d080ff7b8&username=example&password=example&insecure=cool
另外,似乎所有的功能'JSON API用户'也包含'JSON API Auth'插件(为用户认证生成Auth Cookie,验证Auth Cookie,获取当前用户信息)。你为什么同时使用?我认为'JSON API用户'就足够了。 – andreivictor