06-04-2020 15:01
06-04-2020 15:01
I'm learning to code with Javascript and wanted to rock with some intraday Fitbit data.
I made the app for "personal" use, not client or server side.
I've added the OAuth URL into my HTML as a <a href> but keep getting this page.
https://share.getcloudapp.com/qGuK0Gvv
What am I missing?
Again, I'm learning to code and work with Web APIs so if you can help the simpler the explanation the better. THank you and love Fitbit!
06-05-2020 09:52
06-05-2020 09:52
Hi @jonuswakefield,
Welcome to the forums!
It's expected for this page to show up as blank if you are using localhost as your callback URL. The callback URL redirects your user back to your application's website after they consent to share your data. If the callback URL (localhost:5500/callback) does not redirect back to a valid site, then you will get a blank page. If you're testing the auth flow for personal reasons, localhost will suffice; but if you'd like to provide optimal user experience, you should update your callback to redirect users back to your app's web page.
Since your callback URL wasn't pointed to an actual page, you need to manually take the auth code and use it in the Access Token Request endpoint in order to receive an access_token and refresh_token pair.
POST https://api.fitbit.com/oauth2/token
Authorization: Basic (Base 64 clientId:clientSecret)
Content-Type: application/x-www-form-urlencoded
Content-Length: (Size of payload)
client_id=<clientId>&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fexample.com%2Ffitbit_auth&code=<insert_code_here>
I hope this helps. Let me know if you have any additional questions.