Open SuzukiTakamasa opened 4 months ago
def get_secret(project_id, secret_id, version_id="latest"): client = secretmanager.SecretManagerServiceClient() secret_name = f"projects/{project_id}/secrets/{secret_id}/versions/{version_id}" response = client.access_secret_version(name=secret_name) secret_data = response.payload.data.decode('UTF-8') return secret_data
project_id = 'your-gcp-project-id' secret_id = 'your-secret-id'
credentials_json = get_secret(project_id, secret_id)
Google Sheets APIの有効化とクレデンシャルファイルの取得:
Google Cloud Consoleで新しいプロジェクトを作成し、Google Sheets APIを有効化します。 サービスアカウントを作成し、JSON形式のクレデンシャルファイルをダウンロードします。