import requests
d={}
with open("/root/mcp-servers/google-workspace/.env") as f:
 for l in f:
  if "=" in l: k,v=l.strip().split("=",1); d[k]=v
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"]
h={"Authorization":"Bearer "+tk}
meta={"name":"Slide113_Oradores.png"}
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"]
with open("/tmp/slide113.png","rb") as fp:
 r3=requests.put(loc,data=fp,headers={"Content-Type":"image/png"})
fid=r3.json()["id"]
print(f"https://drive.google.com/file/d/{fid}/view")
