How to Connect Google Drive with WordPress Media Library

How to Connect Google Drive with WordPress Media Library

Google Drive is a cloud storage service released by Google and that is trusted by millions of users worldwide to store overloaded content on website. By default, there is 15GB online storage free for you to hold any files, such as photos, sketches, texts, video, audio, and so on. No matter where you are, the files can be managed on computer, notebook, or any other mobile devices.

Since the build-in media library storage can no longer satisfy your needs, connecting Google storage in WordPress is a great option for you. Here, we would like to do so by means of Google Drive WP Media, which is designed for Google Drive integration and helps users upload files to Google Drive from WordPress sites with ease.

Install Google Drive WP Media

Sign up an account on Google if you have not created one and that will be used to log into Google Drive site. Access to Google.com and create an account with your Gmail. Since everything gets ready, log into your WP admin and get started to install Google Drive WP Media. Click “Install Now” if you get the following search result. And then, an item “Google Drive WP Media” is included in Media option.

Install Google Drive WP Media

Connect Google Drive with Your Media Library

Go to Media > Google Drive WP Media and a notice said “This plugin requires api key to authorize your drive” pops up. Confirm it and focus on Settings tab where requires you to enter several details about Google Drive API Key, including Google Email, Client ID, Service Account Name and Private Key Url Path.

Click to Documentation tab > Google Drive API and that shows you a step-by-step guide to generate a Google Drive API key. First of all, visit https://code.google.com/apis/console/ with your Gmail account and here comes out a “Create project” button. Click it and then check the box to agree with the Terms of Service.

Create New Project

Under Projects > API Project > APIs & auth, multiple APIs are available for you, in terms of Google Cloud, Google Maps, Advertising, Google Apps, and so on. Target Drive API and that is included in Google Apps APIs section.

Google Drive API

Click Drive API item and turn to the Drive API setting page. This is where to you to access resources from Google Drive. Click “Enable API” button and the three newly emerging tabs, including Overview, Usage and Quotas, make room for the details information of your Google Drive.

Enable Google Drive API

Move to the left column where includes an option called “Credentials”. Two options are available for you, including QAuth and Public API Access. Click “Create new Client ID” under QAuth. Select “Service Account” option and “Create Client ID”.

Create New Clients ID

A list of details about your service account are generated, including client ID, email address and certificate fingerprints.

Service Account Information

Besides, your p12 key file is downloaded automatically and that is shown on the bottom of the current browser. Upload this file to Google Drive and get its URL path. Go to https://drive.google.com/, and upload this file to Google Drive interface. Right click this file and proceed with Share > Advanced > Change> On – Public on the web. Finally, click “Save” to confirm all settings.

A URL path like https://drive.google.com/file/d/{fileId}/view?usp=sharing is shown in the “Link to share” field and the “{fileId}” is the file ID to be saved. Go back to WP admin > Media > Google Drive WP Media > Settings. Enter your Google email, client ID, service account name and private key URL path one by one.

Note that, the service account name should be the “Email Address” that you have generated in the previous steps. Besides, the private key URL path is commonly in the form of https://docs.google.com/uc?id=XXXXXX&export=download while the “xxxxxx” should be replaced to your file ID. Click “Save” button since have all details done.

Google Drive WP Media Settings

And now, you have successfully integrated Google Drive with your website and that enables remote file management on WordPress website. What’s more, the connection with Google Drive makes it much easier for webmasters to share web content from site to this powerful Cloud storage platform. The shortcode [gdwpm id=”GOOGLE-DRIVE-FILE-ID”] makes it possible for you to preview single file on your site.

In addition to Google Drive WP Media, another option for Google Drive integration named as Google Drive Media Library is also trusted by millions of users and has similarities with the selected plugin in this guide. Give it a try if the current recommendation cannot satisfy your needs.