Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

App auth error

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?

Best Answer
13 REPLIES 13

Hi @423536271827 

 

It's not exactly clear to me what you are doing.   I have a few questions for you.

 

  1. Does this application run on the Fitbit smart watch (Verse, Ionic, Sense) or this is a mobile application?
  2. Are you using the Web APIs to retrieve a user's activity data?
  3. Has a user authorized your application to share their Fitbit data?
  4. Which API(s) are you executing to get the Fitbit data?   Are you getting an error message in your code?

 

Thanks!

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

IT 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
0 Votes

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.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

authd_client = fitbit.Fitbit('23B52F', 'c16643cd3596c02103a2d82f47fb91be',
access_token='https://api.fitbit.com/oauth2/token', refresh_token='<refresh_token>')

Best Answer
0 Votes

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?

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

I'm trying to get a token for the first time.

Best Answer
0 Votes

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....  

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

@GordonFitbit 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
0 Votes

Hi @423536271827 

 

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

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

@GordonFitbit When clicking it it says 

{"errors":[{"errorType":"system","fieldName":"n/a","message":"Authorization Error: Invalid authorization token type"}],"success":false}
Best Answer
0 Votes

It seems to me that you're trying to open a file. Instead, you need to do internet request-response stuff.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Urlrequest.urlopen returns 401 error. @Gondwana

Best Answer
0 Votes

@423536271827 

 

When you receive the 401 Unauthorized error, would you PM the follow items

  1. your client ID
  2. the endpoint that your executing when the error occurs
  3. all of the headers and their values for the above endpoint.

 

Thanks!

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes