I am trying to write a web application with Python using the Fitbit API. I need to authenticate the user with OAuth 2.0 in the browser. Right now I'm trying to use python-fitbit , though I'm not sure there's a better way to do this. 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.
What am I doing wrong here? I feel totally in over my head with this.
Did you notice this known bug in python-fitbit?
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.
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".
I would say that oauthlib call using OAuth2Session should not try to validate the token during the request phase.
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.
Looking for simple example if possible.
@orcasgit/orcas-developers Please review. This should get the OAuth2 authentication working again. Works in my testing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.