05-12-2021 17:51
05-12-2021 17:51
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?
05-13-2021 09:38
05-13-2021 09:38
It's not exactly clear to me what you are doing. I have a few questions for you.
Thanks!
Gordon
05-13-2021 10:10
05-13-2021 10:10
IT is a Windows app. I am using python-fitbit to collect the data. I authorized myself. Without the try/except I got HTTPUnauthorized.
05-13-2021 11:29
05-13-2021 11:29
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.
05-13-2021 11:36
05-13-2021 11:36
authd_client = fitbit.Fitbit('23B52F', 'c16643cd3596c02103a2d82f47fb91be',
access_token='https://api.fitbit.com/oauth2/token', refresh_token='<refresh_token>')
05-13-2021 12:11
05-13-2021 12:11
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?
05-13-2021 12:30
05-13-2021 12:30
I'm trying to get a token for the first time.
05-13-2021 12:57
05-13-2021 12:57
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....
05-13-2021 15:29 - edited 05-13-2021 16:03
05-13-2021 15:29 - edited 05-13-2021 16:03
@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'
05-13-2021 16:18
05-13-2021 16:18
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
05-13-2021 16:56
05-13-2021 16:56
@Gordon-C When clicking it it says
{"errors":[{"errorType":"system","fieldName":"n/a","message":"Authorization Error: Invalid authorization token type"}],"success":false}
05-13-2021 18:47
05-13-2021 18:47
It seems to me that you're trying to open a file. Instead, you need to do internet request-response stuff.
05-14-2021 04:05
05-14-2021 04:05
Urlrequest.urlopen returns 401 error. @Gondwana.
05-18-2021 10:56
05-18-2021 10:56
When you receive the 401 Unauthorized error, would you PM the follow items
Thanks!
Gordon