我正在尝试使用这个名为NodeJS的npm包来制作一个shopify-node应用程序。
请注意,这是一个私有应用程序,它是在Shopify帐户中生成的。我按照文档的指示通过了shopName、apiKey和password。
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: 'your-shop-name',
apiKey: 'your-api-key',
password: 'your-app-password'
});但是,当尝试执行像此GET这样简单的操作时
shopify.product.get()
.then(products => res.send(products))
.catch(err => res.send(err));我收到:
{
"name": "HTTPError",
"hostname": "your-shop-name",
"method": "GET",
"path": "/admin/products.json",
"protocol": "https:",
"statusCode": 401,
"statusMessage": "Unauthorized",
"headers": {...}
}对于所有的Shopify App/JavaScript专家,请告诉我正在忽略的是什么?
发布于 2019-02-21 17:11:34
最后,我的错误是在使用这些绑定时错误地使用了API调用。
而不是:
shopify.product.get()
.then(products => res.send(products))
.catch(err => res.send(err));我应该用这个:
shopify.product.list()
.then(products => res.send(products))
.catch(err => res.send(err));发布于 2019-02-20 03:33:08
检查API键,以确保您已经给它访问产品所需的范围。如果没有要求产品的读写范围,这将是401的一个很好的线索。否则,您将不会按照商店提供给您的内容传递api密钥和密码。
https://stackoverflow.com/questions/54777027
复制相似问题