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

401: Authentication credentials were missing or incorrect

I am using Fitbit4J api in a J2EE application deployed on Tomcat 7.  I have successfully completed OAuth based flow and got the temp token and vefifier after completion of OAuth flow. Next I store that information iin database and later I want to use this information to refresh the user data (number of steps) in my app.

 

 

But I am stuck at this exception

Spoiler
com.fitbit.api.FitbitAPIException: 401: Authentication credentials were missing or incorrect.,

 

Please tell me how to correctly configure APIResourceCredentials object for calling getActivities, for an authenticated user. I can see it has a contructor asking for three parameters where the last one being the tempSecret. How do I get that ? Will it be same for all the a requests ? Please share if you can think about any other cause of this error ?

 

Best Answer
0 Votes
3 REPLIES 3

The exception you're getting is correct.

You can not use temp credentials to make API requests you need temp credentials so you can exchange them for permanent access tokena and secret.

 

Please eplore fitbit oauth debug tool here to better understand the oauth 1.0a flow: https://dev.fitbit.com/apps/oauthtutorialpage

Ivan Bahdanau
Senior Software Developer at Fitbit
Best Answer
0 Votes

Thanks Ivan,

 

Sorry but I really couldn't understand the given link. I have solved the above problem the error was in creating Fitbit user creation which I was doing with localuserId instead of resource id of the resource credentials. That said I have two questions and I know you are the best person to ask them, please help:-

 

  1. You said that "You can not use temp credentials to make API requests", so do you mean that OAUTH_TOKEN and OAUTH_VERIFIER received after OAUTH cycle completion are temproary and are not supposed to store in db ?  If so than how can I get the permanant token using which I can make later API calls to sync the user steps, which I need to show in my app ?
  2. This point is related to the above point, I have noticed that OAUTH_TOKEN and OAUTH_VERIFIER received after OAUTH completion doesn't work after server restart or redeploy of the application. How to solve this problem ?

 

Thanks Buddy,

 

I have really tried to answer this questions on my own but couldn't find a solution. Please help!

 

Best Answer
0 Votes

Answers to both of you questions are at the link that I gave you above: https://dev.fitbit.com/apps/oauthtutorialpage please read it precisely and try to make every step in this debug tool. Based on what you provided you're currently at steps 5-7. You need to do steps 8-10.

Also please read https://wiki.fitbit.com/display/API/OAuth+Authentication+in+the+Fitbit+API#OAuthAuthenticationintheF...

it has very good description of oauth 1.0a flow which answers both of your questions.

Ivan Bahdanau
Senior Software Developer at Fitbit
Best Answer
0 Votes