gspread API 연동 설정
gspread로 구글 시트 연동을 위한 GCP API 설정 가이드.
gspread로 구글 시트를 파이썬에서 연동하려면 GCP API 설정이 필수야.
-
GCP 설정 & Sheets API 활성화
- GCP 콘솔에서 프로젝트 생성/선택 후, 'API 및 서비스' -> '라이브러리'에서 'Google Sheets API'를 활성화해.
-
서비스 계정 생성 & JSON 키 발급
- 'API 및 서비스' -> '사용자 인증 정보'로 가서 '서비스 계정'을 만들고, 생성된 계정에서 '키' 탭 -> '새 키 만들기' -> 'JSON'으로 키 파일을 다운로드해.
-
구글 시트 공유
- 다운받은 JSON 키 파일 내
client_email을 구글 시트의 '공유' 설정에서 '편집자' 권한으로 추가해야 함.
- 다운받은 JSON 키 파일 내
-
Python 코드 예시 ```python import gspread
gc = gspread.service_account(filename='your-service-account-key.json') spreadsheet = gc.open("Your Spreadsheet Name") worksheet = spreadsheet.worksheet("Sheet1") # 또는 .get_worksheet(0) print(worksheet.get_all_values()) ```
여기서 배울 것
- Google Cloud Platform(GCP)에서 서비스 계정 생성 방법
- Google Sheets API 활성화 절차
- gspread 라이브러리를 이용한 구글 시트 접근 방법
- 서비스 계정 키를 통한 인증 및 시트 공유 설정
원본 파일 보기 (.claude/skills/tn-gspread-api-setup/SKILL.md)
---
name: gspread API 연동 설정
description: This skill should be used when the user asks to set up `gspread` for programmatic access to Google Sheets, including creating a Google Cloud Platform service account, enabling the Google Sheets API, and generating API keys for authentication.
version: 1.0.0
source: /home/son/prj/resume/backup_notes_260317/notion/Tech Note/gspread API fa15bdd395364395a9e1ba8d55534a4d.md
---
# gspread API
기존 계정이 날아감 (클라우드 콘솔 오래 안써서 삭제됨)


gcp에서 새로 생성

api enable

service account 발급


service account 들어가서 add key하면 json으로 받을 수 있음.
share authority
**urustin@haranggotgam.iam.gserviceaccount.com**
(previously activate google sheets api / get key and iam account)
select sheet :
.get_worksheet(index) / worksheet(’string’)
