【问题标题】:"The API you are requesting could not be found" error with fitbit-node packagefitbit-node 包出现“找不到您请求的 API”错误
【发布时间】:2016-11-02 13:05:12
【问题描述】:

我正在为我的高级项目使用 FitBit API,但我不断收到“找不到您请求的 API”。错误。我正在使用 fitbit-node 包,这是导致错误的部分:

router.get('/test', function(req, res) {

    if (req.session.authorized) {
        client.get('/1/user/-/activities/date/today.json', req.session.access_token).then(function(results) {
            res.json(results[0]);
        });
    } else {
        res.status(403);
        res.json({
            errors: [{
                message: 'not authorized'
            }]
        });
    }
});

我正在尝试访问 /1/user/-/activities/date/today.json 端点,但不断收到错误消息。我无法访问除 /profile.json 之外的任何其他端点。 req.session.access_token 是存储的来自身份验证的访问令牌。我对 /profile.json 使用相同的设置。

我正在关注此 repo 中的示例,但无法弄清楚它为什么不起作用:https://github.com/lukasolson/fitbit-node/blob/master/example.js

谢谢!

【问题讨论】:

    标签: node.js oauth-2.0 fitbit


    【解决方案1】:

    删除路径中的/1/user/-。它已经在客户端中。

       router.get('/test', function(req, res) {
    
        if (req.session.authorized) {
            client.get('/activities/date/today.json', req.session.access_token).then(function(results) {
                res.json(results[0]);
            });
        } else {
            res.status(403);
            res.json({
                errors: [{
                    message: 'not authorized'
                }]
            });
        }
    });
    

    【讨论】:

    • 你好,我遇到了和你一样的错误,现在按照你的回答,错误消失了,但结果返回为undefined,你知道为什么吗?谢谢
    猜你喜欢
    • 1970-01-01
    • 2021-11-03
    • 1970-01-01
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    • 2017-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多