Delphi Accessing the Fitbit Web API with Delphi using OAuth

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
Accessing the Fitbit Web API with Delphi using OAuth
January 28, 2021 by Holger Flick

REST services can easily be accessed with Embarcadero Delphi. Contrary to a popular misconception, both the Delphi language and the bundled frameworks have been updated to be ready for today’s programming challenges.

Fitbit devices are rather commonly used when people work out to monitor their heart rate and other vital stats. It is also used for sleep analysis etc. Their Web API allows you to access all the data that has been collected on your personal device.

Most modern Web APIs require you to use the OAuth standard. When connecting to a Web service, the owner of the service wants to know who you are. Traditional scenarios involve sending a user name with a password or a unique key. Still, this assumes that your client application stores this information. Users of your application might not want to store their personal access information in your application. This is exactly where OAuth comes into play.

With OAuth, the service provider, i.e. Fitbit in this example, provides the means to authenticate and authorize. Your client will then receive an access token for all future requests to the service.

Getting this access token is not trivial. A few implementations for the OAuth standard exist in the Delphi world and TMS FNC Cloud Pack provides a base class just for this purpose. In the following video you learn:
  • What is OAuth?
  • What is Fitbit?
  • How to access an OAuth Web service
  • Build the service class
  • Build a VCL client
  • How to understand the information given in the documentation
  • How to read data from the Web service
  • Display data in a chart
I already recorded follow-ups to this video showing how to create a component of the service class that can be dropped on a VCL form for rapid application development. Further, reporting with TMS FlexCel will help to quickly generate reports and offer an alternative means for charting.