Skip to main content
Table of Contents

Getting started with TMS FNC Cloud Google Calendar

Prerequisites

  • TMS FNC Core installed and the runtime package added to the project.
  • TMS FNC Cloud Pack installed.
  • A Google account and an OAuth 2.0 client (client ID and secret) created in the Google Cloud console with the Google Calendar API enabled.

Add the component

  1. Drop TTMSFNCCloudGoogleCalendar onto a form or create it in code.
  2. Set the OAuth credentials (Authentication.ClientID, Authentication.Secret, Authentication.CallBackURL; the callback port is taken from the URL).
  3. Persist tokens and call Connect; once OnConnected fires, call GetCalendars.

The minimal connect sequence — credentials, token persistence, and an OnConnected handler that loads the calendars:

Authenticate and connect to Google CalendarPascalC++
procedure TForm1.SetupCalendar;
begin
  FCalendar := TTMSFNCCloudGoogleCalendar.Create(Self);

  // OAuth 2.0 client credentials from the Google Cloud console (Calendar API enabled).
  FCalendar.Authentication.ClientID := '<your-client-id>.apps.googleusercontent.com';
  FCalendar.Authentication.Secret := '<your-client-secret>';
  FCalendar.Authentication.CallBackURL := 'http://127.0.0.1:8000';
  // The callback port is derived from CallBackURL (CallBackPort is read-only).

  // Persist tokens so the consent screen only appears on first run.
  FCalendar.PersistTokens.Location := plIniFile;
  FCalendar.PersistTokens.Key := TTMSFNCUtils.AddBackslash(TTMSFNCUtils.GetDocumentsPath)
    + FCalendar.ClassName + '.ini';
  FCalendar.LoadTokens;

  FCalendar.OnConnected := CalendarConnected;
  FCalendar.Connect; // opens the browser for consent on first run, then fires OnConnected
end;

procedure TForm1.CalendarConnected(Sender: TObject);
begin
  // Tokens are valid here - safe to query calendars and events.
  FCalendar.GetCalendars;
end;
void __fastcall TForm1::SetupCalendar()
{
  FCalendar = new TTMSFNCCloudGoogleCalendar(this);

  // OAuth 2.0 client credentials from the Google Cloud console (Calendar API enabled).
  FCalendar->Authentication->ClientID = "<your-client-id>.apps.googleusercontent.com";
  FCalendar->Authentication->Secret = "<your-client-secret>";
  FCalendar->Authentication->CallBackURL = "http://127.0.0.1:8000";
  // The callback port is derived from CallBackURL (CallBackPort is read-only).

  // Persist tokens so the consent screen only appears on first run.
  FCalendar->PersistTokens->Location = plIniFile;
  FCalendar->PersistTokens->Key = TTMSFNCUtils::AddBackslash(TTMSFNCUtils::GetDocumentsPath())
    + FCalendar->ClassName() + ".ini";
  FCalendar->LoadTokens();

  FCalendar->OnConnected = CalendarConnected;
  FCalendar->Connect(); // opens the browser for consent on first run, then fires OnConnected
}

void __fastcall TForm1::CalendarConnected(TObject *Sender)
{
  // Tokens are valid here - safe to query calendars and events.
  FCalendar->GetCalendars();
}

Next steps

  • Guides — authentication, managing calendars, and managing events.
  • API reference — full class reference.