I am attempting to make a NodeJS application utilizing this npm package called shopify-node-api
Please note, this is a private app which was generated in the Shopify Partners account. I’ve passed the shopName
, apiKey
and password
as instructed by the documentation.
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: 'your-shop-name',
apiKey: 'your-api-key',
password: 'your-app-password'
});
However, when attempting to perform something as straightforward as this GET:
shopify.product.get()
.then(products => res.send(products))
.catch(err => res.send(err));
I receive:
{
"name": "HTTPError",
"hostname": "your-shop-name",
"method": "GET",
"path": "/admin/products.json",
"protocol": "https:",
"statusCode": 401,
"statusMessage": "Unauthorized",
"headers": {...}
}
To all the Shopify App/JavaScript specialists, please advise on what I am overlooking?
2
Answers
At the end of the day my mistake here was an incorrect use of the API call from using these bindings.
Instead of:
I should have been using this:
Check the API key to ensure you have given it the scope needed to access products. Failure to ask for read/write scope on products would be a good clue as to 401. That or you are not passing the api key and password as per what is presented to you in the shop.