Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shopify-api-node returns status 401 unauthorized for private app

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?

like image 990
markreyes Avatar asked Jun 06 '26 11:06

markreyes


1 Answers

At the end of the day my mistake here was an incorrect use of the API call from using these bindings.

Instead of:

 shopify.product.get()
.then(products =>  res.send(products))
.catch(err => res.send(err));

I should have been using this:

shopify.product.list()
.then(products =>  res.send(products))
.catch(err => res.send(err));
like image 143
markreyes Avatar answered Jun 08 '26 02:06

markreyes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!