jquery - Posting to Wordpress API using oAuth1.0 -
so, spent days getting oauth authentication token , able create posts using postman.
now i'm trying implement authentication on site , getting 401 error. request header looks this:
var createrecipe = new xmlhttprequest(); createrecipe.open("post", "/wp-json/wp/v2/recipes"); createrecipe.setrequestheader("authorization", 'oauth oauth_consumer_key="consumerkey", oauth_token="oauthtokenhere", oauth_signature_method="hmac-sha1",oauth_timestamp="1491374534", oauth_nonce="'+magicaldata.nonce+'", oauth_version="1.0", oauth_signature="myoauthsighere"'); createrecipe.setrequestheader("content-type", "application/json;charset=utf-8"); createrecipe.send(json.stringify(recipedata)); createrecipe.onreadystatechange = function() { if (createrecipe.readystate == 4) { if (createrecipe.status == 201) { console.log('created recipe!'); console.log(recipedata); } else { alert("error - try again."); } } }
Comments
Post a Comment