Skip to content

Microsoft 365 data

Apps can read SharePoint lists, Excel ranges, OneDrive files and other Microsoft Graph data with bunker.m365. This page is how you turn it on and keep it tight.

Requires Microsoft Entra ID sign-in.

  • Apps call Microsoft Graph as the person viewing the app. They see only what that person could already open in SharePoint, OneDrive or Excel.
  • Only Graph scopes on your allowlist can be used, for example Sites.Read.All and Files.Read.All. User.Read (the viewer’s own profile) is part of every Entra sign-in and always works.
  • Read only. Bunker forwards GET requests and nothing else.
  • Only Graph paths Bunker knows are forwarded, each mapped to the scopes that grant it (see below). Anything else, such as /applications or /directoryRoles, is refused.
  • The page never sees a token. Tokens are stored encrypted (AES-256-GCM) on the server and refreshed there.
  • Every Graph call is audited as m365.call, with the person, the app, the path, the status and the time it took.
  1. In Entra, open Bunker’s app registration → API permissions. Add the delegated Microsoft Graph permissions you want to allow and grant admin consent (most *.Read.All scopes need it).

  2. In Admin → Microsoft 365, turn it on and list the same scopes. Or from a terminal:

    Terminal window
    bunker api admin.m365.update --data '{"enabled": true, "scopes": ["Sites.Read.All", "Files.Read.All"]}'
  3. The first time someone uses an app that needs a scope they haven’t granted, Bunker shows a consent dialog, sends them through Microsoft’s consent page and back to the app, then retries the call.

Check the current settings, the scopes Bunker knows and the path rules with bunker api admin.m365.get.

Setting API field Environment
m365.enabled enabled BUNKER_M365_ENABLED On or off. When unset, it is on as soon as scopes are set
m365.scopes scopes BUNKER_M365_SCOPES Delegated scopes pages may use, comma separated
m365.require_approval requireApproval BUNKER_M365_REQUIRE_APPROVAL Only apps on the approved list may use Microsoft 365
m365.approved_sites approvedSites BUNKER_M365_APPROVED_SITES Bunker app addresses approved when requireApproval is on
m365.allowed_sites allowedSites BUNKER_M365_ALLOWED_SITES SharePoint site URLs pages may read. Empty means any site the viewer can open

An environment variable pins the value; the admin page can’t change it then.

Terminal window
bunker api admin.m365.update --data '{
"requireApproval": true,
"approvedSites": ["project-dashboard", "hr-policies"]
}'

Other apps get m365_not_approved with a message naming the app to approve.

Terminal window
bunker api admin.m365.update --data '{
"allowedSites": ["https://contoso.sharepoint.com/sites/PMO", "https://contoso.sharepoint.com/sites/HR"]
}'

With a list set, list, Excel and file reads must point inside those sites, and raw graph() calls to /sites, /drives or /shares must name an allowed site.

The longest matching path wins. A call works when the viewer has granted one of the listed scopes and that scope is on your allowlist.

Graph path Scopes (any one)
/me, /me/photo, /me/memberOf, /me/transitiveMemberOf User.Read
/me/manager, /me/directReports User.Read.All, User.ReadBasic.All
/me/drive Files.Read, Files.Read.All, Files.ReadWrite, Files.ReadWrite.All
/me/drives Files.Read, Files.Read.All
/me/events, /me/calendar, /me/calendars, /me/calendarView Calendars.Read, Calendars.ReadWrite
/me/messages, /me/mailFolders Mail.Read, Mail.ReadBasic
/me/people People.Read
/me/planner, /me/todo, /planner Tasks.Read, Tasks.ReadWrite
/me/joinedTeams Team.ReadBasic.All
/teams Team.ReadBasic.All, TeamSettings.Read.All
/me/insights Sites.Read.All
/users User.ReadBasic.All, User.Read.All
/groups Group.Read.All, GroupMember.Read.All
/sites Sites.Read.All, Sites.ReadWrite.All
/drives, /shares Files.Read.All, Sites.Read.All, Files.ReadWrite.All, Sites.ReadWrite.All

Even with a ReadWrite scope allowed, Bunker only reads.

Scope Lets apps
Sites.Read.All Read SharePoint lists and libraries the viewer can access
Files.Read.All Read OneDrive and SharePoint files the viewer can access (Excel ranges too)
Calendars.Read Read the viewer’s calendar
People.Read Read the viewer’s frequent contacts

Start small. Every scope you add is available to every app (or every approved app), with each viewer’s permissions.

  • Results larger than 8 MB are refused. Ask for less with $top or $select.
  • Identical reads by the same person are cached for 30 seconds, to stay clear of Graph throttling. Saving the settings clears the cache.
  • Graph calls time out after 25 seconds. When Graph is busy (429), the app gets throttled with the wait time.
  • lists.items returns up to 5,000 items (200 by default).