Skip to content

Commit 3fa054a

Browse files
authored
Add how to "Create google-api-key.json"
1 parent 5c0a735 commit 3fa054a

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,47 @@ Make sure to add the following secrets and variables in your GitHub repository s
9797
- `SPREADSHEET_ID`: The ID of your Google Sheets spreadsheet.
9898
- `GITHUB_TOKEN`: The GitHub token for committing changes (automatically provided by GitHub Actions).
9999

100+
To create a `google-api-key.json` file, follow these steps to generate a Google Cloud service account key for your project. This key will be used to authenticate API requests, such as those made to Google Sheets.
101+
102+
103+
## Steps to Create `google-api-key.json`
104+
105+
### 1. Set Up a Google Cloud Project
106+
1. Go to the [Google Cloud Console](https://console.cloud.google.com/).
107+
2. If you don’t have an existing project, create one:
108+
- Click the dropdown at the top-left corner of the console and select **"New Project"**.
109+
- Enter a name for your project and click **"Create"**.
110+
111+
### 2. Enable the Google Sheets API
112+
1. In the Google Cloud Console, navigate to **APIs & Services** → **Library**.
113+
2. Search for **Google Sheets API** and click on it.
114+
3. Click **Enable** to activate the API for your project.
115+
116+
### 3. Create a Service Account
117+
1. Go to **APIs & Services** → **Credentials** in the Google Cloud Console.
118+
2. Click **Create Credentials** → **Service Account**.
119+
3. Fill out the service account details:
120+
- **Name**: Choose a descriptive name (e.g., `SheetsServiceAccount`).
121+
- **Description**: Optional but recommended.
122+
- Click **Create and Continue**.
123+
124+
4. Assign a role to the service account:
125+
- For Google Sheets, the recommended role is **Editor**.
126+
- Click **Continue** → **Done**.
127+
128+
### 4. Generate a JSON Key File
129+
1. After creating the service account, go back to **APIs & Services** → **Credentials**.
130+
2. Find the service account you just created in the **Service Accounts** section.
131+
3. Click on the service account name to open its details.
132+
4. Go to the **Keys** tab and click **Add Key** → **Create New Key**.
133+
5. Choose **JSON** as the key type and click **Create**.
134+
6. A JSON file will be downloaded to your computer. This is your `google-api-key.json`.
135+
136+
### 5. Share Your Google Sheet with the Service Account **(Important)**
137+
1. Open the Google Sheet you want to access.
138+
2. Share it with the email address of the service account (found in the JSON file under the `client_email` field).
139+
3. Grant the service account **Editor** or **Viewer** access, depending on your needs.
140+
100141
## Running Tests
101142

102143
To run the tests, follow these steps:
@@ -111,4 +152,4 @@ To run the tests, follow these steps:
111152
npm test
112153
```
113154

114-
This will execute all the test files in the `__tests__` directory using Jest.
155+
This will execute all the test files in the `__tests__` directory using Jest.

0 commit comments

Comments
 (0)