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

OAuth 2.0 Access Token Request problem, please help!

I've been struggling with authentication through the Fitbit API for a while now, and after countless hours looking through docs and tutorials I just can't seem to understand how to get OAuth2.0 to work for my needs.

 

All I need to do is create a desktop application to read from the heartrate api and save the information in local files. I initially tried doing this with Javascript and Ruby, but I've switched to trying with Java and I'm still clueless.

 

The biggest thing I don't understand is callback urls, and how I'm supposed to use them to communicate with my program. For example - since I'm making a distributed desktop app, I understand I should use the Implicit Grant flow, but I don't understand exactly how everything connects. 

 

Is it possible to do this through purely javascript/html? If it is, this is what I've been trying to do:

  • User opens the main html file
  • Javascript will check to see if authorized throught the access token url. If not, redirect the user to the auth page.
  • Fitbit redirects to the previous page (??? Not sure what's needed for callback url)
  • App is authenticated

If it isn't possible, what do I need to do to get similar functionality through Java or Ruby?

 

Thanks so much if you're able to help. I've tried so hard to understand and at this point I'm so drained.

Best Answer
0 Votes
1 REPLY 1

Your app should use the Implicit Grant Flow if it's a distributed client app.

 

The callback URL is how Fitbit communicates the access token back to your app.

 

Your callback URL could be a HTML file that your app loads that contains JavaScript to look at the URL fragement and gets the access token. Your app could then save it somewhere.

 

Other native apps use custom URL schemes (e.g. myapp://auth/fitbit/callback ). Search for your particular platform to find out how to implement those.

Best Answer
0 Votes