Connecting to cloud storage in FastReport VCL

2021-09-11

How to authorize FastReport VCL for cloud storages access

Beginning from the first release of FastReport VCL 6 there is an ability to set connections for Dropbox, Google Drive, Box, OneDrive through special components – “Transports”. To improve the experience of internet transports using starts from FastReport VCL 2021.3 we have reworked authorization to OAuth2.0 by using the default browser in the operating system and extend the connection dialog.

Important! For the HTTPS protocol to function properly, the following OpenSSL libraries are required: libssl-3.dll and libcrypto-3.dll. These libraries can be found in the directory with the main demo application. They need to be copied to the application's folder or the system directory.

Content:

What are the benefits of such an approach?

  • The customer uses a familiar and trustworthy browser. Which’s increases security.
  • The application does not require embedding of browser components which decreases application size.
  • Fast connection for customers who are already authorized in a default browser. Does not require another authorization.

The connection process to cloud storage from FastReport VCL 2021.3 is similar and only has differences in setting-up on the cloud storage side. That’s why we start with the base functionality of the connection dialog.

Standard connection to cloud storages dialog

The fields “Client ID” and “Client Secret” are using for authorization data from cloud storage and generate in the control panel of cloud storage. The buttons on the right from authorization fields are using to hide or show information inside these fields. For fast access to a control panel of cloud storage use a button with a question sign-on authorization dialog (Open configuration page). To save the received authorization token just set the “Save authorization token” checkbox.

The authorization token is stored in the system registry or configuration file as encrypted data.

The EncryptionKey property is responsible for the encryption key for selected transport components. This property is only available from the program code. The developer can change the encryption to save authorization data based on a security policy used in the company.

Adding of the transport to the application

Setup of transport

  1. Open Embarcadero Rad Studio components palate and expand “FastReport VCL Internet transports”.
  2. Select a component you want to use and place it on an application form.

It’s possible to use the context menu right on the transport component. That should show a connection dialog to set a connection from IDE. Press the “Edit connection” submenu item.

 

Context menu

By default, transports are using 9898 ports for authorization answers from the default browser.

In case when this port is already in use or you’re planning to use this port in the future, FastReport VCL allows you to change the default port through the ListenerPort property.

Port settings

Further, we will assume using of 9898 port by default.

Now let’s look at the connection stages of these transports:

  • Dropbox.
  • Google Drive.
  • Box.
  • OneDrive.

Important! The user does not need to follow all of the following steps each time for authorization. This setup should be made once by the cloud storage administrator. After all authorization steps are complete those data can be used for other users as well.

Connection to Dropbox

When the user wants to open or save to a file using transport the authorization dialog should appear (in case the user is not already authorized before).

Standard authorization dialog

To open the control panel page of cloud storage press on the button with the question sign on the top right of the authorization window. After Dropbox control panel should appear in a default browser. If the user is not authorized in Dropbox then an authorization page will be displayed which can be used to login into Dropbox.

Dropbox new application

On this page, you need to select API, access level, and set application name.

Dropbox application setup

Next press the “Create app” button. The application is created. It should automatically redirect to the application options page. We need to scroll down the page and find the “App key” and “App secret” fields.

Dropbox application setup

Just copy the “App key” and “App secret” fields to the FastReport VCL authorization dialog.

Authorization dialog

Return to a default browser with the setup page and set “Redirect URIs” filed to “http://localhost:9898” and press the “Add” button.

Pay attention, the port in the hyperlink should be the same value as the ListenerPort property of the transport component.

Host and port name

In addition, you can set other settings like the lifetime of authorization token.

Setup of an authorization token

Now we need to set access rights for the application. Go to the “Permissions” tab and set checkboxes in front of access rights (read and write, reading of file list and etc.). 

Access rights setup

After all the checkboxes are set, press “Submit”.

Now we can return to FastReport VCL and put “Save authorization token” and “Remember properties” checkboxes if we need to save authorization data. Press “Ok”. The default browser should appear. A user has to log in. When authorization is done connection warning will be shown.

Window with warning

Press “Continue” and the next dialog should appear.

Access confirmation

Press the “Allow” button. You will see a message with a suggestion to close the window.

Close window message

Our application is set and ready to use.

Standard file explorer dialog in FastReport VCL

At this stage, we can send files to cloud storage.

Connection to Google Drive

The standard authorization dialog is the same for all transport filters and you can use descriptions from the above. Let’s move to the setup properties of Google Drive. You can call it by using the button with a question sign.

If this account doesn’t have any projects created to work with Google API, we need to create one as a first step.

Connection to Google Drive

Push the “Create project” button.

Connection to Google Drive

Enter the name of the project and push “Create”.

Select project

Use the “Select project” button to choose an active project.

Select Google Drive project

Select the project created before and push “Open”.

Select type of user access

Switch to the “OAuth consent screen” category. We need to select a user’s type who are going to use this cloud storage: internal use with access only for organization users or for all Google accounts. After that hit the “Create” button.

Fill application settings

Next enter the name of the application and contact e e-mail. Hit  “Save and continue”.

Scopes setup

In this step, we can set up scopes and we can skip it for Google Drive. Push the “Save and continue” button.

The next step allows set up access to the application for user groups. If you would like to publish access to the application – skip this step. Hit “Save and continue”.

The application created moves to the “Back to dashboard” tab.

The “Back to dashboard” tab

Switch to the “OAuth consent screen” tab and push the “PUBLISH APP” button. This will create access to the application. Open this link and turn on Google Drive API, for an active project hit the “Enable” button.

Google Drive API

Now we need to create authorization keys. Switch to the “Credentials” tab.

Creating of authorization keys

Hit on the “Create Credentials” and select “OAuth client ID”.

“OAuth client ID”

The next step is to select an application type (Desktop App in our case).

Application type - Desktop App

Enter any name of the application and hit the “Create” button. The client for authorization is created.Creation of client

Just copy values of the “Client ID” and “Client Secret” fiends in the same fields on the FastReport VCL authorization dialog.Filling with data

Push the “Ok” button. Now we will see a new tab in the default web browser. Select an account for authorization.

Authorization

Next warning about the unsafe application may appear. Hit the “Advanced” and  Go to Name of Application (unsafe).

Warning message

Another access dialog will be shown. Select access rights and push the “Continue” button.

Access request

Now you can close the web browser window.

When the connection was successful FastReport VCL default file explorer will appear.

Connection was successful

Connection to Box

The standard authorization dialog is the same for all transport filters and you can use descriptions from the above. Let’s move to the setup properties of Box. You can call it by using the button with a question sign.

Box welcome message

Hit the “Create New App” button.

New application

Then select an application type. We are using “Custom App”. Next set an authorization method and name of the application.

Select “OAuth 2.0”

Select “OAuth 2.0” and enter the application name. Push the “Create App”. Then Scroll down next page with configuration settings to the “Client ID” field.

Configure the application

Copy values of “Client ID” and “Client Secret” fields to the same fields on the FastReport VCL authorization dialog.

Enter connection info

Go back to the web browser with the settings page.

Application settings

Fill the “OAuth 2.0 Redirect URI” field with this link http://localhost:9898.

 

Pay attention, the port in the hyperlink should be the same value as the ListenerPort property of the transport component.

 

Set “Write all files and folders stored in Box” checkbox if you need write access rights.

Access rights

Push the “Save Changes” button.

Go back to the FastReport VCL dialog and hit “Ok”.

Box authorization

A new window will be shown with suggestions to login. After authorization hit “Grant access to Box”.

When the connection was successful FastReport VCL default file explorer will appear.

Successful connection

Connection to OneDrive

The first step is the same. You can check it in the Connection to Dropbox part above. Let’s open Microsoft Azure settings.

Login into Microsoft account

First of all, we need a new application. Push the “Register an application” button. On the next step enter the application name and Redirect URI (bottom of the page).

Account setup

Push the “Register” button. It will create the application.

“Client ID” field value

Now copy “Client ID” into the FastReport VCL authorization dialog. Open the “Certificates & secrets” category.

Move to the next category

Hit “New client secret”.

New client secret

Enter a description and expiration time. Hit “Add”.

Copy secret value

Now copy secret from the “Value” field into the FastReport VCL authorization dialog.

Fill with data

Push the “Ok” button. New window with default web browser will be shown with suggestions to log on.

Logon

After authorization hit нажмите “Yes”.

Successful connection

We have finished the connection setup. Now we know how to connect to each of could storages supported by FastReport VCL.

November 20, 2024

Localization and Language Switching in FastReport VCL

FastReport VCL supports 40 languages for interface localization and allows you to change the language on the fly through menus or code, without recompilation.
November 01, 2024

New Features of the FastReport VCL Editor

We are considering new features of the report editor: extension lines, highlighting of intersecting objects, updated report and data trees.
October 30, 2024

Using Styles When Creating Reports in FastReport VCL

The article discusses one of the new features of FastReport VCL — the use of styles and style sheets.
Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 66 Canal Center Plaza, Ste 505, Alexandria, VA 22314

© 1998-2024 Fast Reports Inc.