Skip to content

Commit 008a4e8

Browse files
Vitexusoz-agent
andcommitted
Add two-phase SharePoint check example to credential prototype guide
Document the multiflexi-microsoft365 checkAvailability() token+REST verification pattern as a real-world availability-check example. Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent faa9c27 commit 008a4e8

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

source/development/credential-prototype.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,30 @@ The ``ttl`` parameter (seconds) tells the executor how long to cache the result.
408408
Use shorter TTLs for transient failures (60 s) and longer for successes (300 s).
409409
Rate-limited APIs should return a long TTL even on success to avoid burning quota.
410410

411+
Example: Two-Phase SharePoint Check
412+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
413+
414+
The ``multiflexi-microsoft365`` package is a real-world example. Acquiring an
415+
Office 365 token is **not** proof of access: the legacy Azure ACS app-only
416+
endpoint can return a syntactically valid token (HTTP 200) that SharePoint
417+
Online then rejects (HTTP 401 ``invalid_request``) at the tenant level, so a
418+
check that only verifies "I got a token" reports a false positive.
419+
420+
Its ``checkAvailability()`` therefore runs two phases:
421+
422+
1. **Token** — acquire a token, preferring the modern Entra ID v2
423+
``client_credentials`` grant (scope ``https://{tenant}.sharepoint.com/.default``)
424+
and falling back to legacy ACS.
425+
2. **REST** — make a real call (``GET /_api/web/title``) through the
426+
``vgrem/php-spo`` library, wrapped in a retry that resets the SDK's cached
427+
token once (a transient ACS hiccup can otherwise poison every later request).
428+
429+
The outcome maps to ``Unavailable`` for transient failures (timeout, 5xx,
430+
network) and ``Misconfigured`` for permanent ones (bad/expired secret, or a
431+
token that SharePoint rejects — check tenant ``DisableCustomAppAuthentication``,
432+
the app-only grant at ``_layouts/15/appinv.aspx`` and the secret's expiry). The
433+
client secret authenticates the probe but is never written to any diagnostic.
434+
411435
Packaging Checklist
412436
-------------------
413437

0 commit comments

Comments
 (0)