2016-04-29 35 views
1

我有問題的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的

http://example.org/api/user/generate_auth_cookie/?nonce=+4d080ff7b8&username=example&password=example

下面是響應:

{"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."} 

爲什麼我得到這個錯誤?

回答

5

看來,JSON API UserJSON API Auth插件默認只允許通過https連接。

爲了關閉此設置,你應該在請求發送一個額外的參數:

insecure=cool 

所以請嘗試以下要求:

http://example.org/api/user/generate_auth_cookie/?nonce=+4d080ff7b8&username=example&password=example&insecure=cool 
+0

另外,似乎所有的功能'JSON API用戶'也包含'JSON API Auth'插件(爲用戶認證生成Auth Cookie,驗證Auth Cookie,獲取當前用戶信息)。你爲什麼同時使用?我認爲'JSON API用戶'就足夠了。 – andreivictor