【发布时间】:2019-11-30 23:38:21
【问题描述】:
我在我的 Tesla (https://teslaapi.dev/) 上使用 Smartcar API,之前成功发出过请求,但我认为访问令牌已过期,我不知道如何刷新它。
我遵循了这个指南:https://smartcar.com/docs/integration-guides/express/request/ 它讨论了访问令牌,但没有告诉我如何获取刷新令牌。
// ./index.js
app.get('/vehicle', function(req, res) {
// TODO: Request Step 2: Get vehicle information
return smartcar.getVehicleIds(access.accessToken)
.then(function(data) {
// the list of vehicle ids
return data.vehicles;
})
.then(function(vehicleIds) {
// instantiate the first vehicle in the vehicle id list
const vehicle = new smartcar.Vehicle(vehicleIds[0], access.accessToken);
return vehicle.info();
})
.then(function(info) {
res.render('vehicle', {
info: info,
});
});
});
这不再起作用了: { "error": "authentication_error", "message": "提供的令牌无效或过期。" }
我认为这是因为我需要将 accessToken 替换为刷新令牌。我该怎么做?
【问题讨论】:
标签: node.js api oauth oauth-2.0 automotive