You can create Document Library files that link to files in Google Drive™ and Google Photos™. This lets you access your Google files from the Document Library. Note that this functionality isn’t available by default. To enable it, you must complete these steps:
-
Install the Liferay Plugin for Google Drive™ from Liferay Marketplace.
-
Create and/or configure a Google project capable of communicating with your Liferay DXP instance. The Google Picker API must be enabled for this project. This API lets you select Google files to link to. You must also create the credentials the Google project needs to communicate with your Liferay DXP instance.
-
Configure your Liferay DXP instance to communicate with your Google project.
This article shows you how to complete these steps and finishes with an example of linking to a Google file from the Document Library.
Install the App
First, you must install the the Liferay Plugin for Google Drive™ from Liferay Marketplace. This app is available via the following links for Liferay CE Portal and Liferay DXP:
If you need help installing apps from Marketplace, see the documentation on using Marketplace.
Configure Your Google Project
Follow these steps to create and/or configure your Google project so it can communicate with your Liferay DXP instance:
-
Go to the Google API Console. If you don’t have a suitable project, create a new one.
-
Enable the Google Picker API for your project. For instructions, see the Google API Console documentation on enabling and disabling APIs.
-
Create an OAuth 2 client ID in your Google project. For instructions, see the Google API Console documentation on setting up OAuth 2.0. Enter these values when creating your client ID:
- Application type: Web application
- Name: Google Docs Hook
- Authorized JavaScript origins:
[liferay-instance-URL]
(e.g.,http://localhost:8080
is the default for local development machines) - Authorized redirect URIs:
[liferay-instance-URL]/oath2callback
-
Create a new API key in your Google project. For instructions, see the Google API Console documentation on creating API keys. Be sure to restrict the key to HTTP referrers (web sites), and set it to accept requests from your Liferay DXP instance’s URL.
Your new OAuth client ID and public API access key now appear on your Google project’s Credentials screen. Keep this screen open to reference these values as you specify them in Liferay DXP.
Configure Liferay DXP’s Google Apps Settings
Configure your Liferay DXP instance with the client ID and API key that you created in the previous step:
-
Navigate to Control Panel → Configuration → Instance Settings.
-
Click the Miscellaneous tab and expand the Google Apps section.
-
For Google Apps API Key, enter the Google API key that you created in the previous section.
-
For Google Client ID, enter the Google OAuth client ID that you created in the previous section.
-
Save your changes.
Creating Linked Files
With the preceding configuration steps complete, you can create files in your Document Library that link to files in Google Drive™ or images in Google Photos™. Follow these steps to do so:
-
In your Document Library, click the Add button (
) and select Google Docs. The New Google Docs screen appears.
-
Click the Select File button to open Google’s file picker.
-
Use the file picker to select a file from Google Drive™ or Google Photos™.
-
Click Publish.
Figure 1: You can select files from Google Drive™ or your photos.
A new file entry appears for the Google document you linked to. You can view the
file entry as you would any file entry. The Google document’s contents show in
the file entry’s preview pane. As with any file entry, the Options button
()
gives you access to the Download, Edit, Move, Permissions, Move to Recycle Bin,
and Checkin/Checkout/Cancel Checkout options.