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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -