FitBit 中的无效访问令牌

Invalid Access Token in FitBit

我正在尝试将 Fitbit SDK 集成到我的 iOS 应用程序中。我已经在 fitbit 上创建了项目,现在我 运行 在 Postman 中 API 检查个人资料,但作为回应它显示我无效的访问令牌,

{
"errors": [
    {
        "errorType": "invalid_token",
        "message": "Access token invalid: 39ec7defa6f0e33b314bbf6217279b15. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."
    }
],
"success": false

} 这是我的 API https://api.fitbit.com/1/user/-/profile.json,这是我传入的 header,Authorization : Bearer Client Secret 但它向我显示状态代码 401 having error of invalid access token 。我怎样才能获得我的应用程序的访问令牌?

您需要从 FitBit 身份验证服务获取 OAuth2.0 令牌,然后才能调用 API 上的任何其他端点。您需要将您的应用程序重定向到 Safari 并转到 fitbit 身份验证服务,以便用户可以登录并授权您的应用程序访问他们的 FitBit 数据。然后回调将 return 您可以在后续请求中传递的 OAuth 令牌。

你需要这样调用:

https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=%@&scope=%@&redirect_uri=%@"

这是授权的官方 fitbit 文档:

https://dev.fitbit.com/build/reference/web-api/oauth2/