简体   繁体   English

如何使用OAuth 2.0对Fitbit用户进行身份验证?

[英]How to authenticate Fitbit user with OAuth 2.0?

I am trying to write a web application with Python using the Fitbit API. 我正在尝试使用Fitbit API用Python编写Web应用程序。 I need to authenticate the user with OAuth 2.0 in the browser. 我需要在浏览器中使用OAuth 2.0对用户进行身份验证。 Right now I'm trying to use python-fitbit , though I'm not sure there's a better way to do this. 现在,我正在尝试使用python-fitbit ,尽管我不确定是否有更好的方法可以做到这一点。 Here is my code: 这是我的代码:

import fitbit
client = fitbit.FitbitOauth2Client('client_id', 'client_secret')
res = client.make_request("https://api.fitbit.com/1/user/-/activities.json", None, method='GET')

When I run it, I get ValueError: Missing access token. 当我运行它时,我得到ValueError: Missing access token. What am I doing wrong here? 我在这里做错了什么? I feel totally in over my head with this. 我对此深感不安。

Did you notice this known bug in python-fitbit? 您是否注意到python-fitbit中的这个已知错误?

https://github.com/orcasgit/python-fitbit/issues/70 https://github.com/orcasgit/python-fitbit/issues/70

Seems like it might be what you're hitting. 好像是您要击中的东西。 That user described a workaround in using another fitbit python client. 该用户描述了使用另一个fitbit python客户端的解决方法。

Edit: Adding quote from other article for a better answer! 编辑:添加其他文章的报价以获得更好的答案!

As I successfully obtain my token using another Fitbit API client ( https://github.com/magnific0/FitBit.py ), it seems there is a problem with your script "gather_keys_oauth2.py". 当我使用另一个Fitbit API客户端( https://github.com/magnific0/FitBit.py )成功获取令牌时,脚本“ gather_keys_oauth2.py”似乎出现了问题。

I would say that oauthlib call using OAuth2Session should not try to validate the token during the request phase. 我会说使用OAuth2Session的oauthlib调用不应尝试在请求阶段验证令牌。

Looks like the issue was fixed in the code ( gather_keys_oauth2.py ) a week or so ago, but I couldn't find the documentation how to use the fixed code. 看起来该问题已在一周左右的时间内通过代码( collect_keys_oauth2.py )解决,但我找不到如何使用固定代码的文档。

Looking for simple example if possible. 如果可能,寻找简单的例子。

@orcasgit/orcas-developers Please review. @ orcasgit / orcas-developers请查看。 This should get the OAuth2 authentication working again. 这样可以使OAuth2身份验证再次起作用。 Works in my testing. 在我的测试中有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 OAuth 2.0 for BigQuery API 对最终用户进行身份验证,并将 python 作为云函数中的后端代码 - How to authenticate an end user with OAuth 2.0 for BigQuery API with python as a backend code in cloud function Flask OAuth 2.0 授权码流 使用 Fitbit 的授权令牌无效 API - Flask OAuth 2.0 Authorization Code Flow Invalid Authorization Token with Fitbit API 如何使用用户名为别名的OAuth2.0对Office365用户进行身份验证? - How to authenticate Office365 users using OAuth2.0 where username is alias? 如何使用 Basecamp 2 API 和 oAuth 2.0 作为最终用户发送评论 - How use Basecamp 2 API with oAuth 2.0 to send a comment as end user 无法使用 Fitbit API 进行身份验证,昨天工作,不知道如何解释错误日志 - Failure to authenticate using Fitbit API, worked yesterday, no idea how to interpret error log 无法使用Oauth2.0对LinkedIn Python API客户端进行身份验证 - Unable to authenticate LinkedIn Python API client using Oauth2.0 如何允许非管理员用户通过OAuth2.0对不允许用户代表他们同意应用的租户进行身份验证? - How to allow non-admin users to authenticate via OAuth2.0 for tenants where users are not allowed to consent apps on their behalf? 如何手动验证用户 - How to manually authenticate user OAUTH2 - Fitbit使用requests_oauthlib - OAUTH2 - Fitbit using requests_oauthlib 如何添加OAuth 2.0提供程序? - How to add OAuth 2.0 providers?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM