Files
fn_registry/python/functions/bigquery/bq_auth.md
T
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

57 lines
1.6 KiB
Markdown

---
name: bq_auth
kind: function
lang: py
domain: infra
version: "1.0.0"
purity: impure
signature: "def bq_auth(project_id: str = '', credentials_path: str = '') -> BQClient"
description: "Autentica contra Google BigQuery con ADC o service account JSON. Retorna un BQClient listo para usar con todas las funciones CRUD."
tags: [bigquery, gcp, auth, google-cloud, python, pendiente-usar]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: [google-cloud-bigquery]
params:
- name: project_id
desc: "ID del proyecto GCP (vacio = detectar de credenciales/entorno)"
- name: credentials_path
desc: "ruta a archivo JSON de service account (vacio = Application Default Credentials)"
output: "BQClient: cliente autenticado con proyecto resuelto"
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/bigquery/client.py"
---
## Ejemplo
```python
from bigquery import bq_auth
# ADC (gcloud auth application-default login)
client = bq_auth()
# Proyecto explicito
client = bq_auth("my-project-id")
# Service account
client = bq_auth(credentials_path="/path/to/service-account.json")
# Context manager
with bq_auth() as client:
# client se cierra automaticamente
pass
```
## Notas
Tres modos de autenticacion:
- Sin argumentos: usa Application Default Credentials (ADC) — requiere `gcloud auth application-default login`
- Con project_id: usa ADC pero fuerza el proyecto
- Con credentials_path: lee el JSON de service account directamente
El BQClient wrappea `google.cloud.bigquery.Client` y expone `_client` para que las funciones del modulo lo usen internamente.