Skip to content
All projects
Core engineering libraryData Manager

m365_graph.py — Microsoft Graph Client

BCHPR · Microsoft 365 estate · 2023 – present

5,573-line Microsoft Graph client wrapping 73 distinct operations across Entra ID users and groups, SharePoint sites and lists, Microsoft Planner, and Teams. Planner is the centre of gravity at 43% of the file — activity tracking across study sites.

Highlights

  • App-only OAuth 2.0 client-credentials flow; GraphUsers holds a TTL-checked token and refreshes on expiry.
  • Resumable bulk Planner task creation — JSON checkpointing, deduplication against existing tasks, parallel ETag fetching, and batch size that adapts up on a 90% success rate and down below 50%.
  • ETag-based optimistic concurrency on every Planner write, matching Planner's mandatory concurrency model.
  • Graph $batch wrapper chunked to the 20-request limit, with responses correlated back by request id.
  • Respects Retry-After on 429 and 503 with exponential backoff and jitter; @odata.nextLink pagination throughout.
  • One-call directory export flattening each user's manager into manager_* columns via a second $expand pass.