@sentry/junior-google
Proof of concept. Junior uses its own Google Workspace account, such as
junior@example.com, to schedule meetings, read Meet transcripts, read
Google Docs, Sheets, and Slides that are shared with that account, create
and edit Google Docs, and edit Google Slides. Junior does
not use the Google credentials of the people it helps.
Setup
- In the Google Cloud project of the dashboard OAuth client, enable the
Calendar, Docs, Drive, Sheets, and Slides APIs.
- Use an Internal consent screen. Add the scopes
calendar.events.freebusy, calendar.events.readonly,
calendar.events.owned, documents, drive.file, drive.readonly, and
presentations.
After you add a scope, reconnect the account in step 7.
- Add the redirect URIs
https://<junior host>/api/plugins/google/oauth/callback and
http://127.0.0.1:8765/oauth/callback (CLI).
- Give the Junior account a Workspace license.
- Set
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET,
GOOGLE_WORKSPACE_ACCOUNT_EMAIL, and optionally
GOOGLE_WORKSPACE_ALLOWED_DOMAINS.
- Run
junior upgrade, then junior admin grant <email> for each admin.
- Connect the account on Admin → Google account in the dashboard, or run
junior google connect.
Anyone who can talk to Junior can read the calendars that the Junior account
can see. Share calendars with that account only when that is acceptable.
Junior reads a Doc, Sheet, or Slides file, or its comments, only for a
requester who can open it too. This is the check that link cards use: the
file names the requester, anyone with the link can open it, or the
requester's domain can open it and owns it. Access through a Google group
does not count.
One tool, readGoogleFile, reads all three. It takes the type from the link,
or from Drive for a bare file id.
Search finds only files that any employee could already find in Drive, and
files shared with the requester by name. Files shared by link, or only with
other people or groups, never show up in search. Search also drops every file
that no account in GOOGLE_WORKSPACE_ALLOWED_DOMAINS owns. Shared-drive files
have no owner, so search shows them only when they are shared with the
requester by name. Search returns nothing for a requester outside those
domains.
The dashboard shows a card for a Doc, Sheet, Slides, Drive file, Drive
folder, or Calendar event link only when the signed-in viewer can open it
too. A file must name the
viewer's email as a reader, writer, or owner, be open to anyone with the
link, or be open to the viewer's domain and owned in that domain. Access
through a Google group gets no card. An event must be on the Junior
account's calendar, with the viewer as its organizer, creator, or a guest.
A file card shows the title, type, owner, and modified time. A Drive link to
a Doc, Sheet, or Slides file shows the same card as its Docs link. Other
Drive files also show a thumbnail. The image route checks the viewer again
on each read, and sends Junior's credential only to Google's thumbnail host.
An event card shows the title and time. Cards never show guests.
Junior edits a Doc only for a requester who can edit it through their own
email, their domain, or an editable link. Access through a Google group is not
checked. The plugin enforces this for every change to an existing Drive file:
each write operation declares how it checks the requester, and a file write
fails unless the tool passes the file that the editor check returned. Junior makes the requester the owner of a Doc it
creates, then removes its own access. Google emails the requester about the
new ownership. Junior cannot read or edit that Doc again unless the requester
shares it back. This only works for requesters in the same Workspace
organization as Junior's account.
Each edit of an existing Doc needs the revision_id that readGoogleFile or
the last edit returned. If someone changed the Doc after that, the edit is
refused, so Junior never changes text that it did not read.
Slides edits follow the same rules. Junior edits a presentation only for a
requester who can edit it. updateGoogleSlides sends Slides API
batchUpdate requests at the revision_id that readGoogleSlidesLayout or
the last edit returned. A Sheets chart needs a Sheet that the requester can
open too, and only YouTube videos can be added, because Junior cannot check
who can open a Drive video. Junior does not refresh a Sheets chart, because
the request does not name the chart's Sheet. getGoogleSlideThumbnail renders a slide so Junior
can check its work. The sandbox downloads the rendered image, which needs no
credential.
createGoogleSlides makes the requester the owner of a presentation that
Junior creates. Unlike a Doc, Junior's account stays an editor, so Junior can
build the deck over many edits. The read and edit checks still apply, so
Junior reads or changes the deck only for people who can open or edit it
themselves. The requester can remove Junior's account in the sharing
settings.
Google fetches an inserted image from a URL that needs no credential, and
keeps that URL in the deck. So Junior publishes a sandbox image as a public
artifact that stops serving after 5 minutes, gives Google its URL, and
unpublishes it when the edit ends. If the install cannot publish artifacts,
only public image URLs work.
Plugin setup: https://junior.sentry.dev/extend/