Table of Contents

Getting started with TMS FNC Cloud Microsoft OneDrive

Prerequisites

  • TMS FNC Core installed and the runtime package added to the project.
  • TMS FNC Cloud Pack installed.
  • An app registered in the Microsoft Entra admin center with a client ID, client secret, and a registered redirect URI.

Add the component

  1. Drop TTMSFNCCloudMicrosoftOneDrive onto a form (or create it in code).
  2. Set the app credentials on Authentication (client ID, secret, redirect URI).
  3. Call Connect to authenticate, then call OneDrive operations from OnConnected.

Minimal example

Set the credentials, connect, and request the account info once connected:

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Credentials from your app registration (https://portal.azure.com).
  TMSFNCCloudMicrosoftOneDrive1.Authentication.ClientID := 'your-client-id';
  TMSFNCCloudMicrosoftOneDrive1.Authentication.Secret := 'your-client-secret';
  // Must match a redirect URI registered on the app.
  TMSFNCCloudMicrosoftOneDrive1.Authentication.CallBackURL := 'http://127.0.0.1:8000';

  TMSFNCCloudMicrosoftOneDrive1.OnConnected := OneDriveConnected;
  // Opens the Microsoft consent page in the browser and exchanges the code for tokens.
  TMSFNCCloudMicrosoftOneDrive1.Connect;
end;

procedure TForm1.OneDriveConnected(Sender: TObject);
begin
  // Tokens (including a refresh token) are now available on Authentication.
  TMSFNCCloudMicrosoftOneDrive1.GetAccountInfo;
end;

Next steps