Skip to content
cccskills
FreePublished on GitHub

bigquery-auth

GCPプロジェクト単位でBigQuery認証を設定するスキル。gcloud設定プロファイルで複数プロジェクトを安全に分離管理。「BigQueryに繋ぎたい」「BQ認証」「gcloud認証」「データ分析の認証設定」等のリクエストで発動。

The English summary is being prepared. Showing the original description.

Works withGoogle Cloud
See how to install

Files included (4)

  • SKILL.md5.0 KB
  • agents/openai.yaml255 B
  • SKILL.en.md4.6 KB
  • SKILL.es.md5.0 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

トリガーワード

「BigQuery認証」「BQ繋ぎたい」「データ分析の認証」「gcloud認証」

BigQuery Authentication (Project-based)

GCPプロジェクト単位でgcloud設定プロファイルを作成し、BigQuery認証を行うスキルです。

Workflow

  1. ユーザーが「BigQuery使いたい」「{プロジェクト}のデータを見たい」等と言う
  2. GCPプロジェクトIDを確認(必須)
  3. 既存の設定プロファイルを確認
  4. 必要に応じて新規プロファイルを作成
  5. ブラウザ認証をガイド
  6. 接続テストを実行

認証手順

Step 1: 設定プロファイル確認

gcloud config configurations list

既存プロファイルを表示し、目的のプロジェクト用があるか確認。

Step 2: プロファイル作成(新規の場合)

# プロファイル作成
gcloud config configurations create {PROFILE_NAME}

# プロジェクト設定
gcloud config set project {PROJECT_ID}

Step 3: gcloud認証

# メイン認証(ブラウザが開く)
gcloud auth login

# Python SDK用認証(ブラウザが開く)
gcloud auth application-default login --quiet

注意: 両方のコマンドでブラウザ認証が必要です。

Step 4: 認証確認

# 現在のプロファイル確認
gcloud config configurations list

# プロジェクト確認
gcloud config get-value project

# ADCトークン確認
gcloud auth application-default print-access-token

Step 5: BigQuery接続テスト

import os
# 環境変数競合を回避
if "GOOGLE_APPLICATION_CREDENTIALS" in os.environ:
    del os.environ["GOOGLE_APPLICATION_CREDENTIALS"]

from google.cloud import bigquery
client = bigquery.Client(project="{PROJECT_ID}")
datasets = list(client.list_datasets())
print(f"接続成功!{len(datasets)}個のデータセット")

プロファイル切り替え

# プロファイル一覧
gcloud config configurations list

# 切り替え
gcloud config configurations activate {PROFILE_NAME}

登録済みプロファイル(テンプレート)

ADC認証(gcloud login)

プロファイルプロジェクトIDアカウント用途
default{YOUR_PROJECT_ID}{YOUR_EMAIL}デフォルト
{PROFILE_2}{PROJECT_ID_2}{EMAIL_2}分析用

自分のプロジェクト情報に置き換えてください。

サービスアカウント認証(外部プロジェクト)

プロファイルプロジェクトIDキーファイル用途
{SA_PROFILE}{SA_PROJECT_ID}~/.gcp/{SA_KEY_FILE}.json外部プロジェクト分析

サービスアカウント認証の使い方

外部プロジェクトにサービスアカウントで接続する場合:

import os
from google.cloud import bigquery
from google.oauth2 import service_account

# サービスアカウントキーで認証
credentials = service_account.Credentials.from_service_account_file(
    os.path.expanduser("~/.gcp/{SA_KEY_FILE}.json")
)

# BigQueryクライアント作成
client = bigquery.Client(
    project="{SA_PROJECT_ID}",
    credentials=credentials
)

# 接続テスト
datasets = list(client.list_datasets())
print(f"接続成功!{len(datasets)}個のデータセット")

トラブルシューティング

エラー原因対処法
File xxx was not foundGOOGLE_APPLICATION_CREDENTIALS が無効unset GOOGLE_APPLICATION_CREDENTIALS
Reauthentication needed認証期限切れ再度認証実行
Permission deniedBigQuery権限なしIAM設定を確認

重要な注意事項

環境変数の競合

GOOGLE_APPLICATION_CREDENTIALS 環境変数が設定されている場合、ADCより優先されます。 Pythonコードで以下を実行して回避:

import os
if "GOOGLE_APPLICATION_CREDENTIALS" in os.environ:
    del os.environ["GOOGLE_APPLICATION_CREDENTIALS"]

marimo notebook使用時

.cursor/rules/notebook.mdc のルールに従い:

  1. 作業開始前に「どのGCPプロジェクトで作業しますか?」と確認
  2. gcloud config configurations list でプロファイル一覧を表示
  3. 必要に応じてプロファイルを切り替え

Requirements

  • Google Cloud SDK (gcloud) インストール済み
  • ブラウザでGoogleアカウントにログイン可能
  • 対象プロジェクトへのBigQuery閲覧権限

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

A/Bテストや実験の設計・実装を支援するスキル。 「A/Bテストを設計して」「スプリットテストしたい」「仮説を立ててテストしたい」「バリアントを比較」等のリクエストで発動。 トラッキング実装は analytics-tracking を参照。

The English summary is being prepared. Showing the original description.

minicoohei/ai-agent-camp346Updated Oct 7, 2026

マルチエージェントシステムのアーキテクチャ設計ツールキット。 「エージェントを設計して」「マルチエージェント構成」「エージェントのアーキテクチャ」「オーケストレーション設計」等のリクエストで発動。

The English summary is being prepared. Showing the original description.

minicoohei/ai-agent-camp346Updated Oct 7, 2026

ai-agent-campのローカル環境セットアップを確認するスキル。 「セットアップ確認」「環境チェック」「初期設定できてる?」「インストール確認」「依存関係チェック」等のリクエストで発動。

The English summary is being prepared. Showing the original description.

minicoohei/ai-agent-camp346Updated Oct 7, 2026

ai-agent-campのスラッシュコマンドをCodexでルーティングするスキル。 「/start-0-1を実行」「スラッシュコマンドを使いたい」「コマンドルーティング」「Cursorのコマンドを使いたい」等のリクエストで発動。

The English summary is being prepared. Showing the original description.

minicoohei/ai-agent-camp346Updated Oct 7, 2026

ai-agent-campの環境変数・認証情報を安全に管理するスキル。 「APIキーを設定」「.envを管理」「環境変数の設定」「credential managerを使いたい」「秘密情報の管理」等のリクエストで発動。

The English summary is being prepared. Showing the original description.

minicoohei/ai-agent-camp346Updated Oct 7, 2026

ai-agent-campリポジトリの案内・オリエンテーションスキル。 「リポジトリ案内」「次のレッスンは?」「どこから始める」「ツールの違い」「aiagent概要」等のリクエストで発動。

The English summary is being prepared. Showing the original description.

minicoohei/ai-agent-camp346Updated Oct 7, 2026

See all skills by minicoohei

Report a problem with this skill