1. Create a project in Google Cloud
Go to Google Cloud Console.
In the top menu, select Create Project.
Specify the project name (for example, MySheetsProject).
Click Create.
2. Enable Google Sheets API
In the project, go to the menu APIs & Services → Library.
Find Google Sheets API.
Click Enable.
3. Create credentials
Depending on how you plan to use the API, there are two options:
🔹 Option 1. If you will work on your own behalf (for example, a script for yourself)
Go to APIs & Services → Credentials.
Click Create Credentials → OAuth client ID.
Set up the OAuth Consent Screen, choose External or Internal, specify your email and name.
Choose the application type:
Desktop app (if it's a script for PC)
Web app (if it's a server)
Download the JSON file with the keys (client_secret.json).
Upon first launch, your script will request authorization in the browser and save the token.
🔹 Option 2. If you need the script/bot to have access without confirmation
(for example, a server that works with the spreadsheet itself)
Go to APIs & Services → Credentials.
Click Create Credentials → Service account.
Specify a name (for example, sheet-bot).
Save the JSON file (this is the service key).
Open your spreadsheet in Google Sheets and share access with the service account email (it will look like xxxxx@project-id.iam.gserviceaccount.com).
4. Check access
Open Google Sheets and create a spreadsheet.
Copy its ID from the URL:https://docs.google.com/spreadsheets/d/<ID>/edit
Use the gspread or google-api-python-client library, specifying the spreadsheet ID and keys.
⚡ Done — after this, your code will be able to read and write to Google Sheets.