Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Building a Google Drive VCL application using Enterprise Connectors

 

Step 1: Download and install the Google Drive Enterprise Connector Trial

In RAD Studio 10.2 (Pro or higher), navigate to the GetIt Package Manager via the Tools menu. Select the Connectors category and search for ‘Drive’ and proceed with the installation. 

Step 2: Create your VCL application

Go to File > New > VCL Forms Application > Delphi.

In the Data Explorer, right click on CData GoogleDrive Data Source and select Add New Connection. I named my connection ‘GDrive’.

Next, drop the TFDPhysGoogleDriveDriverLink and TFDConnection components onto your form. With the TFDConnection component selected, select CDataGoogleDrive as the DriverName and GDrive as the ConnectionDefName. Next, open the Connection Editor and set InitiateOAuth to GetAndRefresh.

To execute ad-hoc SQL statements based on this connection, enter SQL commands on the SQL Script tab. In this demo, I am looking to access all PNG files from my Google Drive (see screenshot below).

Next, add a FDGUIxWaitCursor onto your form. To display the data, drop a DBGrid onto your form and align it to the client. See the screenshots below for the properties you need to set for each of the components.

 

Set up an OnCreate event:

[crayon-67688f145b5cb087301972/]

 

Run your application

After setting InitiateOAuth to GETANDREFRESH, you are ready to connect. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken connection property. When you connect, the component opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The component then completes the OAuth process: 

1.Extracts the access token from the callback URL and authenticates requests.

2.Refreshes the access token when it expires.

3.Saves OAuth values to be persisted across connections. This file can be configured in OAuthSettingsLocation. 

After the OAuth process has been completed, you will see the data in your VCL application.  

 

 

Screenshot of my Google Drive folder, containing a number of different files.

 

You can easily build a full featured application that includes the ability to upload new files to Google Drive,delete files, change descriptions and more. Below are screenshots of a FireMonkey sample application that my colleague Andrew recently built:

 

To learn more about our Enterprise Connectors offering, please visit https://www.embarcadero.com/products/enterprise-connectors

 


SPECIAL END OF THE QUARTER DEALS – Up to 35% OFF or 22 months of Maintenance – OFFERS END September 30th, 2017

With savings on Professional, Enterprise, and Architect editions, or Maintenance, there is something for everyone. Save 15% on Professional, up to 35% on Enterprise or Architect, or get extended support with 22 months of maintenance, FREE. Click here to learn more.

 

Exit mobile version