import requests,json
with open("/root/mcp-servers/google-workspace/.env") as f:
  d={l.split("=",1)[0]:l.split("=",1)[1].strip() for l in f if "=" in l}
r=requests.post("https://oauth2.googleapis.com/token",data={"client_id":d["GOOGLE_CLIENT_ID"],"client_secret":d["GOOGLE_CLIENT_SECRET"],"refresh_token":d["GOOGLE_REFRESH_TOKEN"],"grant_type":"refresh_token"})
tk=r.json()["access_token"]
print("Token OK")
h={"Authorization":"Bearer "+tk}
meta={"name":"Sesion BNI Privilegio 24 marzo 2026 ACTUALIZADA.pptx"}
u="https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable"
r2=requests.post(u,headers={**h,"Content-Type":"application/json"},json=meta)
loc=r2.headers["Location"]
print("Upload URI obtained")
with open("/tmp/out.pptx","rb") as fp:
 r3=requests.put(loc,data=fp,headers={"Content-Type":"application/vnd.openxmlformats-officedocument.presentationml.presentation"})
fid=r3.json()["id"]
print(f"Uploaded! File ID: {fid}")
print(f"https://drive.google.com/file/d/{fid}/view")
