Ad

Authorization With API Key And Password For Request-promise

I am trying to make a GET call to the shopify api with request-promise in node. I keep getting this error :-

'401 - {"errors":"[API] Invalid API key or access ' + 'token (unrecognized login or wrong password)"}'

How should format the options to take an API key and password?

const request = require("request-promise");
const Parse = require('parse/node');


const options = {
  method:'GET',
  json: true,
  uri: 'https://the-bib-wine-company.myshopify.com/admin/api/2019-07/orders.json',
  headers: {
   'Authorization': <api key and password encode64>
  }
}


request(options)
  .then(function(response) {

var Test = Parse.Object.extend("Test");
    var test = new Test();

test.set('orders', 'success');
    test.save();

  })
  .catch(function(err) {
    console.log(err)
  })
Ad

Answer

Answered my own question, if it helps anyone.

auth: { 'user': 'API key', 'pass': 'mypassword' }

Ad
source: stackoverflow.com
Ad