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":"Oradores BNI 24 marzo","mimeType":"application/vnd.google-apps.folder"}
r2=requests.post("https://www.googleapis.com/drive/v3/files",headers={**h,"Content-Type":"application/json"},json=meta)
fid=r2.json()["id"]
requests.post(f"https://www.googleapis.com/drive/v3/files/{fid}/permissions",headers={**h,"Content-Type":"application/json"},json={"role":"writer","type":"anyone"})
print(f"Folder ID: {fid}")
print(f"https://drive.google.com/drive/folders/{fid}")
