Creating a Google Service Account
This page walks you through creating a Google service account and downloading its JSON key file. You only need to do this once per WordPress site, and it's the prerequisite for connecting M Chart Pro charts to private Google Sheets.
Why this is needed
M Chart needs a way to read your private Google Sheets without you handing over your personal Google password. A service account is a separate Google identity that you grant per-sheet access to, then point M Chart at by uploading its JSON key file. After setup you share each sheet with the service account's email address, exactly the same way you'd share a sheet with a colleague.
Before you start
- A Google account, any free Gmail address works
- About 5 minutes
- You do not need to enable billing or pay for anything. The Google Sheets API has a free tier that easily covers normal M Chart use.
Step 1, Open Google Cloud Console
Go to console.cloud.google.com and sign in with your Google account.
If this is your first time signing in, Google may ask you to agree to its terms of service and pick a country. Accept and continue, you do not need to start a free trial or add a credit card.
Step 2, Create a project
A "project" in Google Cloud is just a container for the things you set up, in this case, the Sheets API access and the service account itself. It costs nothing to create.
- At the top of the page, next to the Google Cloud logo, click the project picker dropdown. It shows the current project name, or Select a project if none is selected.
- In the dialog that opens, click New Project in the top-right.
- In the Project name field, type a name you'll recognize later,
M Chartis a good choice. - Leave the Location field as is.
- Click Create.
Google will take a few seconds to create the project and then switch to it automatically. Confirm the project name now shows in the picker at the top of the page before continuing.
Step 3, Enable the Google Sheets API
Each Google API has to be turned on per-project before you can use it.
- Click the navigation menu (the three-line icon at the top left, sometimes called the "hamburger" menu).
- Choose APIs & Services → Library.
- In the search box, type
Google Sheets API. - Click the Google Sheets API result.
- Click the Enable button.
Enabling can take a few seconds. When it finishes you'll be taken to the API's overview page, that means it worked.
Step 4, Create a service account
- Click the navigation menu (☰) again.
- Choose IAM & Admin → Service Accounts.
- Click Create service account at the top of the page.
- In the Service account name field, type a name.
M Chartis a good choice. - Notice that the Service account ID field auto-fills from the name. This becomes part of the email address you'll use to share sheets later. You can leave it as is.
- The Service account description field is optional, leave it blank or add a note like
Used by M Chart to read shared sheets. - Click Create and continue.
- The next screen, Grant this service account access to project, is optional. Skip it. M Chart does not need a project-wide role; it gets access to sheets one at a time when you share them. Click Continue.
- The final screen, Grant users access to this service account, is also optional. Skip it too. Click Done.
You'll land back on the Service Accounts list with your new service account in the table.
Tips
The service account's email address looks something like m-chart@your-project-12345.iam.gserviceaccount.com. You don't need to memorize or copy it now, M Chart will display it for you after you upload the JSON key in the next steps.
Step 5, Download the JSON key
The "key" is a small file that proves to Google that M Chart is allowed to act as this service account.
- In the Service Accounts list, click the service account's email address to open its details page.
- Click the Keys tab near the top of the page.
- Click Add key → Create new key.
- In the dialog that opens, choose JSON as the key type. It's selected by default.
- Click Create.
The JSON file downloads to your computer automatically, usually to your Downloads folder. The filename looks something like your-project-12345-abc123.json.
This is the only copy
Google does not keep a copy of the key. If you lose this file you'll have to come back here and create a new one.
Step 6, Keep the JSON file safe
Caution
The JSON key file lets anyone who has it read every Google Sheet that's been shared with the service account. Treat it like a password.
- Don't email it.
- Don't commit it to a Git repository.
- Don't paste it into chat tools, support tickets, or screenshots.
- After you've uploaded it to M Chart, you can safely delete the local copy.
Next steps
You're done in Google Cloud Console. Head back to your WordPress site and finish the setup:
- Open the JSON file in a plain text editor (or right-click → Open with → any text editor). It will look like a long block of text starting with
{. - Select all of the contents and copy it.
- In WordPress, go to Chart → Settings and find the Google Sheets, Service Account section.
- Paste the JSON into the Service Account field and save.
Full details are on the External Data Sources page, including how to share individual sheets with the service account email.
Troubleshooting
"I can't find the project picker." It's at the very top of the page, just to the right of the Google Cloud logo. It either shows the current project name or the words Select a project.
"I don't see APIs & Services / IAM & Admin in any menu." You need to open the navigation menu first, click the three-line icon (☰) at the top-left of the page, near the Google Cloud logo.
"Google is asking me to start a free trial or enable billing." You can dismiss those prompts. The Google Sheets API has a free tier that covers normal M Chart use, and creating a service account itself is free.
"The Service account ID field is greyed out." That field auto-fills as you type the name. If you want a different ID, click directly inside the field and edit it before clicking Create and continue, it can't be changed after the service account is created.
"I shared a sheet with the service account email but M Chart still says permission denied." Open the sheet in Google Sheets and click Share again. Confirm the service account email appears in the list of people with access. Google's share dialog occasionally fails to add an external address silently, if it's missing, paste the email in and click Send (or Share). Viewer access is enough.
"I lost the JSON file." Come back to IAM & Admin → Service Accounts, click your service account, open the Keys tab, and create a new key. You don't need to make a new service account. You can also delete the old key from this page once the new one is working.