I added the app to my Dev screen, and used the Python file from the repo. I have two LEDs in my program. a "Connected" green LED and an "Auth error" red LED. But every time I launch the app, it's saying 0 steps, 0 calories, etc, the green LED stays off, and the red LED turns on every time I launch the program. What should I do to successfully auth the program?
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
It's not exactly clear to me what you are doing. I have a few questions for you.
Thanks!
Gordon
Best AnswerIT is a Windows app. I am using python-fitbit to collect the data. I authorized myself. Without the try/except I got HTTPUnauthorized.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Would you please post the endpoint that you're executing which receives the HTTP Unauthorized error? Also, include the headers and their values EXCEPT for the access token.
Best Answerauthd_client = fitbit.Fitbit('23B52F', 'c16643cd3596c02103a2d82f47fb91be',
access_token='https://api.fitbit.com/oauth2/token', refresh_token='<refresh_token>')
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Are you trying to exchange the authorization code for the access token and refresh token, or are you trying to refresh an expired access token?
Best AnswerI'm trying to get a token for the first time.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Thank you. I'm going to provide you with the API syntax, but you'll need to translate that into your python code. The syntax is
POST https://api.fitbit.com/oauth2/token
Authorization: Basic <basic token>
Content-Type: application/x-www-form-urlencoded
client_id=<client_id>&grant_type=authorization_code&redirect_uri=<callback URL value>&code=<authorization code>
The authorization code can be found appended to the redirect_URL after the user consents.
I don't think the code you provided is providing the correct information. If you want to test the authorization process with your own client settings, we provide the OAuth 2.0 Tutorial to help with that. See https://dev.fitbit.com/build/reference/web-api/troubleshooting-guide/debugging-tools/#oauth-2-0-tuto....
Best Answer@Gordon-C I got an OSError when trying to open the activity log.
act_list=open('https://api.fitbit.com/1/user/-/activities/date/2021-05-13.json', 'r')
OSError: [Errno 22] Invalid argument: 'https://api.fitbit.com/1/user/-/activities/date/2021-05-13.json'
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Sounds like you got past the authorization error. Great news! This new error is not coming from the Web APIs. Researching the error online, it seems the error related to your python code syntax. We do not support the developer communities open source projects. So, maybe one of the community developers can assist with this error.
If you want to test the endpoints outside of python, I can suggest a few free tools you can use to make certain the data is available.
Gordon
Best Answer@Gordon-C When clicking it it says
{"errors":[{"errorType":"system","fieldName":"n/a","message":"Authorization Error: Invalid authorization token type"}],"success":false}
Best AnswerIt seems to me that you're trying to open a file. Instead, you need to do internet request-response stuff.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
When you receive the 401 Unauthorized error, would you PM the follow items
Thanks!
Gordon
Best Answer