Create OAuth Client - knpy/yuka-app GitHub Wiki
- Google Cloud Console にアクセス
- プロジェクトを選択(または新規作成)
- 左側メニューから「APIs & Services」→「Credentials」を選択
- 「+ CREATE CREDENTIALS」をクリック
- 「OAuth 2.0 Client IDs」を選択
初回の場合は先にOAuth consent screenの設定が必要:
- 「OAuth consent screen」タブを選択
- User Type: 「External」を選択(個人開発の場合)
- 必要な情報を入力:
- App name: yuka-app
- User support email: あなたのメールアドレス
- Developer contact information: あなたのメールアドレス
- 「Scopes」セクションで「ADD OR REMOVE SCOPES」をクリック
- 以下のスコープを追加:
.../auth/userinfo.email
.../auth/userinfo.profile
.../auth/calendar.readonly
- 「Credentials」タブに戻る
- 「+ CREATE CREDENTIALS」→「OAuth 2.0 Client IDs」
- Application type: 「Web application」を選択
- Name: 「yuka-app-web-client」など適切な名前
- Authorized JavaScript origins:
-
http://localhost:3000
(開発環境) - あなたの本番ドメイン(例:
https://your-app.amplifyapp.com
)
-
- Authorized redirect URIs:
-
http://localhost:3000/api/auth/callback/google
(開発環境) -
https://your-app.amplifyapp.com/api/auth/callback/google
(本番環境)
-
作成後に表示される以下の情報を安全に保存:
- Client ID
- Client Secret
.env.local
ファイルに以下を追加:
GOOGLE_CLIENT_ID=your_client_id_here
GOOGLE_CLIENT_SECRET=your_client_secret_here
NEXTAUTH_SECRET=your_nextauth_secret_here
NEXTAUTH_URL=http://localhost:3000
- Client Secret は絶対に公開しないこと
- 本番環境では適切なドメインでリダイレクトURIを設定すること
- スコープは必要最小限に設定すること
一般的な問題については OAuth Troubleshooting を参照してください。