Setting up a Service Account
Part 1: Creating a GCP Service Account
Step 1: Access Google Cloud Console
Navigate to Google Cloud Console
Sign in with your Google account
Select an existing project or create a new one from the project drop-down at the top of the page
Step 2: Navigate to Service Accounts
In the left sidebar, click on IAM & Admin
Select Service Accounts from the sub menu
You'll see a list of existing service accounts (if any)
Step 3: Create a New Service Account
Click the + CREATE SERVICE ACCOUNT button at the top
Fill in the service account details:
Service account name: Choose a descriptive name (e.g., "sheets-data-extractor")
Service account ID: Auto-generated based on the name (you can customize it)
Description: Optional but recommended (e.g., "Service account for extracting Google Sheets data")
Click CREATE AND CONTINUE
Step 4: Grant Permissions (Optional)
For basic Google Sheets access, you can skip this step by clicking CONTINUE, then DONE. The service account doesn't need project-level permissions to access sheets that are explicitly shared with it.
Part 2: Obtaining the Service Account Email
After creating the service account, you'll be returned to the Service Accounts list page.
Locate your newly created service account in the list
The Email column displays the service account email address
Format:
[email protected]
Copy this email address - you'll need it to share your Google Sheet
Important: Share Your Google Sheet
To allow the service account to access your Google Sheet:
Open your Google Sheet
Click the Share button
Paste the service account email address
Set appropriate permissions (typically "Viewer" for read-only, "Editor" for write access)
Uncheck "Notify people" since it's a service account
Click Share
Part 3: Creating and Downloading the Service Account Key
Step 1: Access Key Management
In the Service Accounts list, click on your service account name
Navigate to the KEYS tab at the top
Click ADD KEY drop-down
Select Create new key
Step 2: Generate the Key
A dialog will appear asking for the key type
Select JSON (recommended format)
Click CREATE
Step 3: Secure Your Key
The JSON key file will automatically download to your computer
IMPORTANT: Store this file securely
Never commit it to version control (add to
.gitignore)Don't share it publicly
This key provides full access to resources the service account can access
Rename the file to something memorable (e.g.,
sheets-service-account-key.json)
Key File Structure
The downloaded JSON file contains:
{
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "key-id",
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "client-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "cert-url"
}Part 4: Enabling the Google Sheets API
Step 1: Navigate to APIs & Services
In the GCP Console left sidebar, click APIs & Services
Select Library from the sub menu
Step 2: Search for Google Sheets API
In the search bar at the top, type "Google Sheets API"
Click on Google Sheets API from the search results
Step 3: Enable the API
Click the ENABLE button
Wait a few seconds for the API to be enabled
You'll be redirected to the API dashboard showing the API is now enabled
Verification
You can verify the API is enabled by:
Going to APIs & Services > Enabled APIs & services
Confirming "Google Sheets API" appears in the list
Last updated
Was this helpful?

