Fitbit application for drupal site

Hi, I had to create custom module to implement fitbit intergation on one of our drupal sites. I really like fitness and most part of my drupal sites are dedicated to  this theme. Fitbit is a very interesting system which collect user data such as quantity of calories during the day, quantity of steps and on theirs basis calculates fitness activity. As I think it is very good and challenging to have one of fitbit devices which track your activity and make it visible to your friends, colleagues etc. 

So this is just my opinion now lets talk about drupal implementation. First of all we should use OAuth php library because it will make great amount of work for us.  According to fitbit api references we will create a system with authentication flow shown on referenced diagram. First of all we need to create fitbit account and create our application. We should follow  this page https://dev.fitbit.com/login and create new account. Then we need to register new app https://dev.fitbit.com/apps/new 

After app creation you should follow Manage my apps tab and click on your application link. You will see application settings you need to remeber "Client (Consumer) Key"  and "Client (Consumer) Secret" we need this values to get initial access to fitbit when users will allow us to get theirs data. 

In my case I didn't want to create drupal users for fitbit users. Drupal actually is not very fast for authenticated users and giving access into drupal can lead to privileges escalation. So I just created page where any user can give us access to his fitbit data.

I have created custom_fitbit module to make possible fitbit integration with drupal. Before creating this module I looked at drupal.org and found couple modules which was fitbit related. They didn't match my needs.

Inside custom_fitbit module we have custom_fitbit_display module which show results of our fitbit users.

Module is quite easy to understand for drupal developers. The main idea is that any user can go to certain url and give our website access to his/her fitbit data, during fitbit authentication user can upload image, fill name etc. This module just show one of multiple ways of fitbit drupal iplementation.

Please ask questions in comments.

Thank you for reading!

 

 

//Please wrote code!