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}
fid='1ZVN66HNGV9mNxvTCg-PfH68NXK30qkuv'
q=f"'{fid}' in parents"
r2=requests.get("https://www.googleapis.com/drive/v3/files",headers=h,params={"q":q,"fields":"files(id,name,mimeType,size)"})
print(r2.json())
ids={"12h12_NNvQtz-D9iHIkjS4KV1rDGVGi2a":"/tmp/adrian_onepage.pdf","1G6VcEZrK3j4eCUxlwZyoGG7G8KeoF2lF":"/tmp/adrian_video.mp4",
"1Dpl_yzalme6UaEhSmhyNrsV-KZSJipL8":"/tmp/paula_pres.pptx"}
for fid,path in ids.items():
 u=f"https://www.googleapis.com/drive/v3/files/{fid}?alt=media"
 r=requests.get(u,headers=h)
 with open(path,"wb") as f: f.write(r.content)
 print(f"Downloaded {path}: {len(r.content)} bytes")
