Fenix / generar_token.py
Tu Nombre
Reinicio total: Agencia Limpia y Segura
fc25d6b
Raw
History Blame Contribute Delete
1.26 kB
import os
from google_auth_oauthlib.flow import InstalledAppFlow
import json
# Archivos
SECRETS_FILE = 'client_secret_2.json'
TOKEN_SALIDA = 'token1.json'
# Permisos totales de escritura y anclaje
# Permisos totales de escritura, subida y anclaje
SCOPES = [
"https://www.googleapis.com/auth/youtube.upload", # <--- ESTA ES LA LLAVE DE SUBIDA 🚀
"https://www.googleapis.com/auth/youtube.force-ssl", # Para comentarios y anclaje 💬
"https://www.googleapis.com/auth/youtube", # Gestión total
"https://www.googleapis.com/auth/youtube.readonly" # Solo lectura
]
def main():
if not os.path.exists(SECRETS_FILE):
print(f"❌ Error: No encuentro {SECRETS_FILE} en esta carpeta.")
return
# Configuramos el flujo para dispositivos sin pantalla (consola)
flow = InstalledAppFlow.from_client_secrets_file(SECRETS_FILE, SCOPES)
# Esto te dará un link. Ábrelo, logueate y pega el código aquí.
creds = flow.run_local_server(port=8080, prompt='consent', open_browser=False)
# Guardamos el token
with open('token.json', 'w') as token:
token.write(creds.to_json())
print("\n✅ ¡token.json generado con éxito!")
if __name__ == "__main__":
main()