使用 API 密钥和密码授权请求承诺
Authorization with API key and password for request-promise
我正在尝试使用节点中的请求承诺对 shopify api 进行 GET 调用。
我不断收到此错误:-
'401 - {"errors":"[API] Invalid API key or access ' +
'token (unrecognized login or wrong password)"}'
如何格式化选项以获取 API 密钥和密码?
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)
})
回答了我自己的问题,如果对大家有帮助的话。
auth: {
'user': 'API key',
'pass': 'mypassword'
}
我正在尝试使用节点中的请求承诺对 shopify api 进行 GET 调用。 我不断收到此错误:-
'401 - {"errors":"[API] Invalid API key or access ' + 'token (unrecognized login or wrong password)"}'
如何格式化选项以获取 API 密钥和密码?
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)
})
回答了我自己的问题,如果对大家有帮助的话。
auth: {
'user': 'API key',
'pass': 'mypassword'
}