Our documentation has been relocated here, the Liferay Developer Network. Please update your bookmarks!

You can access files stored in Google applications, such as Google Drive™ and Google Photos™, through the Document Library. This integration isn’t available by default, but you can get it by installing the Liferay Plugin for Google Drive™ from the Liferay Marketplace.

You must configure Liferay Portal to access Google’s Picker API, which accesses files stored on Google’s servers. Invoking the Google Picker API requires unique API keys and a client ID. The API keys are for accessing public data and the client ID is for authenticating and authorizing user access to non-public data. To get the keys and client ID, you must use a Google developer project. This takes three steps:

  • Step 1: Enable the Google Picker API
  • Step 2: Create Credentials
  • Step 3: Configure Liferay Portal’s Google Apps Settings

Start by enabling the Google Picker API in a Google developer project.

Step 1: Enable the Google Picker API

Liferay Portal uses the Google Picker API to access files in Google.

  1. Create a Google account or use an existing one.

  2. Open the Google Developer Console.

  3. Create a new project or use an existing one.

  4. Search for the Google Picker API and enable it. Liferay Portal uses this API to access Google documents.

Next, you must create credentials to use with the Google API.

Step 2: Create Credentials

  1. In the Google Developer Console, navigate to the Credentials screen for APIs & services.

  2. Create a new OAuth client ID for a Web application. Specify the following attributes:

    • Name: Google Docs Hook
    • Authorized JavaScript origins: [liferay-instance-URL] (e.g., http://localhost:8080 by default for local development machines)
    • Authorized redirect URIs: [liferay-instance-URL]/oath2callback
  3. Create a new API key. Restrict the key to HTTP referrers (web sites), and set it to accept requests from your Liferay Portal instance’s URL.

Your new OAuth client ID and public API access key now appear on the Credentials screen. Keep this screen open to reference these values as you specify them in Liferay Portal. All that’s left is to enter the API key and client ID into Liferay Portal’s Google Apps configuration.

Step 3: Configure Liferay Portal’s Google Apps Settings

To call Google’s APIs, you must configure Liferay Portal with your Google project’s OAuth client ID and public API access key:

  1. Navigate to Control PanelConfigurationInstance Settings.

  2. Click the Miscellaneous tab and expand the Google Apps section.

  3. For Google Apps API Key, enter the Google API key that you created in the previous step.

  4. For Google Client ID, enter the Google OAuth client ID that you created in the previous step.

  5. Save your changes.

Your Liferay Portal instance is now ready to access Google documents from the Document Library.

Linking to Google Docs™

In your Document Library, you can create file entries that link to Google documents, such as files stored in Google Drive™ or photos saved to Google. To link to a Google document in Documents and Media, click the Add icon (icon-add.png) and select Google Docs. The New Google Docs screen appears.

This screen is similar to the edit screen for basic documents, except for file selection. Clicking the Select File button brings up Google’s file picker to select files from your Google Drive™ or your photos. Select the Google file you want to link to and 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 (icon-options.png) gives you access to the Download, Edit, Move, Permissions, Move to Recycle Bin, and Checkin/Checkout/Cancel Checkout options.


Figure 2: The Google document’s file entry view displays the file’s information and provides a preview of the file.

Great! Now you know how to access Google Docs™ from your document libraries. Next, you’ll learn how to display your Document Library’s files on your site.

0 (0 Votes)
Editing Images Previous