gcal-oauth-desktop-setup
Skill0 starsChanged 5 months agoMITView on GitHub
個人GCPプロジェクトでGoogle Calendar APIのOAuth 2.0 Desktop App認証を新規セットアップするとき(既存GCPプロジェクトへの権限がない場合を含む)。
- Reads credentials
- Installs packages
In this repository99 other files it gives its agents.
- agents-tools-quoted-jsonSkill
- asc-api-app-store-submitSkill
- asd-ste100Skill
- automation-bool-selector-pitfallsSkill
- automation-stale-cooldown-flagSkill
- autonomous-build-verifySkill
- book-to-skillSkill
- ccusage-cli-cost-trackingSkill
- chrome-ext-mv3-programmatic-injectSkill
- chrome-ext-store-assetsSkill
- claude-headless-p-invocationSkill
- claude-plugin-context-auditSkill
- claude-session-log-to-kbSkill
- cloudflare-workers-do-deploySkill
- codebase-to-courseSkill
- codesign-keychain-prompt-fixSkill
- codex-cli-setupSkill
- codex-delegation-handoffSkill
- content-factory-grounding-dedupSkill
- conversation-log-append-patternSkill
- cron-to-launchd-macosSkill
- cross-automation-shared-resource-killSkill
- design-token-migration-rnSkill
- discord-bot-image-to-claudeSkill
- discord-gateway-resume-dedupSkill
- excel-filtered-url-http-auditSkill
- execution-budget-vs-capsSkill
- expo-free-local-ios-testflightSkill
- ga4-connect-projectsSkill
- git-commit-helperSkill
- git-prepush-secret-remote-checkSkill
- gsc-cli-automationSkill
- hatena-blogsync-autopostSkill
- hook-latency-wrapSkill
- hook-log-append-patternSkill
- html-to-pdf-slide-deckSkill
- humanizerSkill
- human-review-gate-shellSkill
- implementation-model-routingSkill
- insights-to-claude-mdSkill
- ios-permission-key-security-matrixSkill
- ios-sim-store-screenshotsSkill
- launchd-exit78-exconfig-debugSkill
- llm-content-pipeline-quality-gateSkill
- local-ai-video-pipelineSkill
- local-flux-mflux-image-genSkill
- local-llm-slow-diagnosisSkill
- local-music-generationSkill
- lottie-skottie-authoring-pitfallsSkill
- machine-wide-api-ratelimit-latchSkill
- macos-hook-path-timeoutSkill
- md-to-docx-reportSkill
- memory-md-inject-bloat-auditSkill
- message-display-secrets-maskSkill
- metric-source-attributionSkill
- migrate-icloud-desktop-assetsSkill
- nextauth-local-e2e-sessionSkill
- nextjs-rsc-payload-slimSkill
- nothing-designSkill
- openclaw-ollama-setupSkill
- The first 60 shown.
The file
Files
Procedure
1. 個人GCPプロジェクトを作成する
- https://console.cloud.google.com/projectcreate を開く(対象Googleアカウントでログイン)
- プロジェクト名を入力(例:
personal-gcal)→「作成」 - 上部プロジェクトセレクタで新規プロジェクトに切り替える
2. Calendar API を有効化する
- https://console.cloud.google.com/apis/library/calendar-json.googleapis.com を開く(プロジェクトが正しいか確認)
- 「有効にする」をクリック
3. OAuth同意画面を設定する
- https://console.cloud.google.com/apis/credentials/consent を開く
- User Type: 「外部」 → 「作成」
- 必須項目を入力:
- アプリ名(例:
gcal-cli) - ユーザーサポートメール(自分のGmailアドレス)
- デベロッパー連絡先(同上)
- アプリ名(例:
- 「保存して次へ」→ スコープ画面では何も追加せず「保存して次へ」
- テストユーザー画面で「+ ADD USERS」→ 自分のGmailアドレスを追加 → 「保存して次へ」
4. OAuth 2.0 クライアントID(Desktop App)を作成する
- https://console.cloud.google.com/apis/credentials を開く
- 「認証情報を作成」→「OAuth クライアント ID」
- アプリケーションの種類: 「デスクトップ アプリ」
- 名前を入力(例:
gcal-cli-desktop)→「作成」 - 「JSONをダウンロード」して安全な場所に保存(例:
~/.config/gcal/credentials.json)
5. 依存パッケージをインストールする
pip install google-auth-oauthlib google-api-python-client6. Pythonスクリプトで初回認証する
import json, os
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
SCOPES = ['https://www.googleapis.com/auth/calendar']
CREDS_FILE = os.path.expanduser('~/.config/gcal/credentials.json')
TOKEN_FILE = os.path.expanduser('~/.config/gcal/token.json')
def get_service():
creds = None
if os.path.exists(TOKEN_FILE):
creds = Credentials.from_authorized_user_file(TOKEN_FILE, SCOPES)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(CREDS_FILE, SCOPES)
creds = flow.run_local_server(port=0)
with open(TOKEN_FILE, 'w') as f:
f.write(creds.to_json())
return build('calendar', 'v3', credentials=creds)初回実行時にブラウザが開き、Googleアカウントで認証する。以降はトークンが自動リフレッシュされ、ブラウザ不要。
Pitfalls
- 既存GCPプロジェクト(他プロジェクト所有)は流用しない。権限エラーになる。個人用は必ず個人所有プロジェクトを作る。
- OAuth同意画面のUser Typeを「内部」にすると Workspace 組織が必要。個人Gmailなら必ず「外部」を選ぶ。
- テストユーザーに自分のアドレスを追加しないと
access_deniedになる(公開ステータスにしない限り)。 credentials.jsonはシークレット扱い。.gitignoreに必ず追加し、絶対にコミットしない。- トークンの保存は
creds.to_json()+Credentials.from_authorized_user_file()を使う。pickleは使わない(任意コード実行リスク)。
Verification
python3 gcal.py
# → ブラウザ認証後(初回のみ)、カレンダー一覧やイベント追加が成功すれば完了以降は token.json が存在する限りブラウザ起動なしでバックグラウンド実行できる。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

