Connect Google Drive (service account setup)
Google Drive Portal connects to Google Drive with a service account: a technical Google identity that you create for free in your own Google Cloud project. You download its key (a small JSON file), give it to the plugin, and share one Drive folder with the service account address. This whole guide takes about 10 minutes.
No OAuth app is needed. This plugin does not use "Sign in with Google". You do not create OAuth credentials, you do not copy any redirect URI, you do not configure a consent screen, and you do not add test users or publish an app. Tutorials that mention those steps are for other plugins. The service account connection does not expire after 7 days and needs no Google verification.
Before you start
- A Google account that can open the Drive folder you want to show (a normal Gmail account or a Google Workspace account).
- The plugin installed and activated (see Install the free version).
- In WordPress, open Drive Documents. Keep this page open in one browser tab: step 1 on the page has direct links to the Google pages used below.
Step A: create a Google Cloud project
A project is a container in Google Cloud that holds your settings. It is free: this plugin uses the Drive API, which has no cost for normal use.
- Go to console.cloud.google.com/projectcreate and sign in with your Google account. If it is your first visit, accept the terms of service.
- In Project name, type a name you will recognise, for example Website documents.
- Leave the other fields as they are and click Create.
- Wait a few seconds, then make sure the new project is selected in the project picker at the top of the console.
You can also use a project you already have.
Step B: enable the Google Drive API
- Open the Google Drive API page (or, in the console menu, APIs and services > Library and search for Google Drive API).
- Check that your project is selected at the top.
- Click Enable.
If you skip this step, the plugin later tells you: The Google Drive API is not enabled on this project.
Step C: create the service account
- Open IAM and admin > Service accounts.
- Click Create service account.
- Give it any name, for example wordpress-portal. Google fills in an ID for you.
- Click Create and continue.
- The next screens ask for roles and user access. Grant nothing: just click Continue and then Done. The service account does not need any Cloud role.
Step D: download the JSON key
- In the list of service accounts, click the one you just created.
- Open the Keys tab.
- Click Add key > Create new key.
- Choose JSON and click Create.
- A
.jsonfile downloads to your computer.
Keep this file safe. It is the password of this connection. Do not email it or put it in a public folder. If you lose it, just create a new key the same way.
"Service account key creation is disabled"? Some Google Workspace organisations block key creation with an organisation policy. Ask your Google Workspace administrator to allow key creation for this project, or create the project with a personal Google account.
Step E: give the key to the plugin
- Go back to WordPress, Drive Documents, box 1. Create the Google service account.
- In the JSON key field, either paste the whole content of the file (open it with any text editor and copy everything, from the first
{to the last}), or click the file button under the field and choose the downloaded file. - Click Save the key.
The plugin checks the key with Google straight away. If it works you see: Key saved and accepted by Google. Now share the Drive folder with ... , as Viewer. The box then shows Connected to Google Drive with the service account address, which looks like name@project-id.iam.gserviceaccount.com.
Step F: share the Drive folder with the service account
The service account cannot see anything in your Drive until you share a folder with it. Sharing is what decides what the portal can show.
- On the plugin page, in box 2. Share the Drive folder, click Copy next to the service account address.
- Open Google Drive and find the folder you want to show on the site.
- Right-click the folder and choose Share (on some screens Share > Share).
- Paste the service account address in the Add people field.
- Set the role to Viewer. Viewer is enough: the plugin never writes to Drive.
- Click Send (or Share). If Google warns that the address is outside your organisation, that is expected: confirm.
- Go back to WordPress and reload the Drive Documents page. The folder appears in the list Folders shared with the service account.
Everything inside the shared folder is visible to the plugin, including subfolders and files you add later. Nothing else in your Drive is.
Share the folder, not a file. Sharing single files does not make them appear. On a shared drive, either add the service account address as a member of the shared drive (the drive then appears in Browse, marked Shared drive), or share a folder inside the drive with that address.
Step G: run the connection check
- In box 1, under Connection check, click Run check.
- The plugin makes real calls to Google and prints what comes back. The last section, Reading, tells you in plain words what to do.
When everything is fine it says: Everything works: the service account sees 1 shared folder. You can pick it with the Browse button in step 3. Now continue with Choose who sees which folder.
Other buttons in box 1
- Replace the key: paste a new key to replace the saved one (for example after deleting the old key in Google Cloud).
- Clear cache: forgets the lists stored by the plugin and asks Google again.
- Remove the key: disconnects the site. The portal stays offline until a new key is saved.
Installing on several client sites
Every site should use its own Google Cloud project and its own service account. Nothing is shared between sites and nothing has to be edited in the code: each site shows its own address to share the folder with.
Write to us and tell us which plugin, what you tried and what you see. We answer from Italy, usually within one working day.