Closed stanshivam closed 5 years ago
I am trying to hit an api which requires oAuth1.0. But, In request headers I see oauth_consumer_key="undefined". And request fails with 404. Am I missing something?
const url = `${WP_API_URL}/register`; const oauth = OAuth({ consumer: { public: customer_key, secret: customer_secret }, signature_method: 'HMAC-SHA1', hash_function(base_string, key) { return crypto .createHmac('sha1', key) .update(base_string) .digest('base64'); } }); const request_data = { url: url, method: 'POST' }; return fetch(url, { method: 'POST', headers: { ...oauth.toHeader(oauth.authorize(request_data)) }, body: JSON.stringify(data) }) .then(function(response) { console.log(response); if (response.status !== 200) { console.log( 'Looks like there was a problem. Status Code: ', response.status ); return; } return response.json(); }) .catch(err => console.log(err));
Needed to send key property instead of public, in consumer object.
I am trying to hit an api which requires oAuth1.0. But, In request headers I see oauth_consumer_key="undefined". And request fails with 404. Am I missing something?