What it scans
| Connection type | Scanned scope |
|---|---|
m365_mail |
Headers, bounded message body text and file attachments in explicitly listed Exchange Online mailboxes; optional folder and received-after filter |
m365_drive |
Files beneath one user's OneDrive for Business root or a relative folder |
m365_sharepoint |
Files beneath one SharePoint site's explicit document library, optionally a relative folder |
The agent uses app-only Microsoft Graph authentication. No interactive user sign-in is needed. These connections are marked Pilot in the console.
What you need
A customer-run agent, network access to
login.microsoftonline.com, graph.microsoft.com and permitted HTTPS download
hosts, and an Entra administrator to register and authorize an app. Mail setup
also needs an Exchange administrator. Secrets stay on your agent. App
permissions can be wider than a connection's scan scope; configure both.
Step 1: Register an app
In Microsoft Entra admin center → Entra ID → App registrations → New
registration, name the app Myrikeep scanning agent, choose Accounts in
this organizational directory only and leave redirect URI blank. Record
Application (client) ID and Directory (tenant) ID from Overview.
Open Certificates & secrets → Client secrets → New client secret. Choose an expiry your team can maintain, copy the Value once, and set a rotation reminder before expiry. The Secret ID is not the credential.
Step 2: Grant read access for your chosen source
Exchange Online mail
Use Exchange Application RBAC to scope Application Mail.Read. As an
Exchange admin, install/use Microsoft's Exchange Online PowerShell tools and
connect. Replace the placeholder IDs; the service-principal Object ID comes
from Enterprise applications, not the app-registration Object ID.
This example uses an unused mailbox custom attribute; agree the attribute with
your Exchange admin before setting it:
Connect-ExchangeOnline
Set-Mailbox -Identity [email protected] -CustomAttribute15 MyrikeepScan
New-ServicePrincipal -AppId '<APPLICATION_CLIENT_ID>' -ObjectId '<ENTERPRISE_APP_OBJECT_ID>' -DisplayName 'Myrikeep scanning agent'
New-ManagementScope -Name 'Myrikeep mailboxes' -RecipientRestrictionFilter "CustomAttribute15 -eq 'MyrikeepScan'"
New-ManagementRoleAssignment -App '<ENTERPRISE_APP_OBJECT_ID>' -Role 'Application Mail.Read' -CustomResourceScope 'Myrikeep mailboxes'
Test-ServicePrincipalAuthorization -Identity '<ENTERPRISE_APP_OBJECT_ID>' -Resource [email protected]
Tag only intended mailboxes. Test a mailbox inside and outside the scope.
Remove any separately granted Entra Mail.Read application permission: grants
are additive, and the RBAC test excludes Entra permissions. Allow propagation
time before a real scan. Older Application Access Policies are a separate,
legacy mechanism; do not treat them as RBAC role assignments. Follow
Microsoft's Application RBAC guide.
OneDrive for Business
Open API permissions → Add a permission → Microsoft Graph → Application permissions. Add Files.Read.All, then Grant admin consent for your tenant. This grants broad file access across the tenant. Selecting one user or folder in Myrikeep narrows scanning, not the app's authority. Use a dedicated app and review whether this broad permission suits your workspace. Do not add write or directory permissions. See Graph Files.Read.All.
SharePoint document library
In the same application-permissions dialog add Sites.Selected, then grant admin consent. Consent alone grants no site access. Using a separate authorized admin tool or Graph Explorer session, grant the scanning app read access to only the selected site:
POST https://graph.microsoft.com/v1.0/sites/<SITE_ID>/permissions
Content-Type: application/json
{"roles": ["read"], "grantedToIdentities": [{"application": {"id": "<APPLICATION_CLIENT_ID>", "displayName": "Myrikeep scanning agent"}}]}
Do not grant the scanning app administrative rights to grant itself access.
See Selected permissions.
For a SharePoint-only app, avoid Files.Read.All or Sites.Read.All, which
would broaden access beyond the selected-site grant.
Step 3: Find scope IDs and add the connection
Use mailbox email addresses for mail and a user's UPN or object ID for OneDrive. For SharePoint, an admin can use Graph Explorer to look up the site and library:
GET https://graph.microsoft.com/v1.0/sites/example.sharepoint.com:/sites/Finance
GET https://graph.microsoft.com/v1.0/sites/<SITE_ID>/drives
Copy the first result's id as Site ID, then the intended library's id as
Drive ID. These are provider IDs, not browser URLs. The agent never lists all
sites or users. In Connections → Add connection, select the corresponding
Microsoft 365 type, enter its scope, assign the agent and choose Local
credential catalog. Prepare the secret below, wait for present, then queue
a scan in Scans.
Connection settings table
| Console field | Example | Required or optional |
|---|---|---|
| Connection name | Finance mail |
Required; unique in workspace |
| Type | m365_mail, m365_drive, m365_sharepoint |
Required; one connection per scope |
| Mailbox IDs (mail) | [email protected] |
Required; one per line or comma-separated, at most 1,000 |
| Mail folder (mail) | inbox or folder ID |
Optional; blank means whole mailbox |
| Received after (mail) | 2026-01-01T00:00:00Z |
Optional; UTC; only newer messages |
| OneDrive owner (drive) | [email protected] |
Required; user ID or UPN |
| SharePoint site ID (SharePoint) | example.sharepoint.com,<site-guid>,<web-guid> |
Required |
| Drive / document library ID (SharePoint) | <LIBRARY_DRIVE_ID> |
Required |
| Root folder path (drive/SharePoint) | Finance/2026 |
Optional; relative, no leading slash or .. |
| Agent | Microsoft agent |
Required; same workspace |
| Credential mode | Local credential catalog | Required |
| Credential name | M365_MAIN |
Required; uppercase alias |
| Exclude patterns (View/edit) | *.tmp |
Optional; one glob per line |
| Enabled (connection row) | Enabled | Disable to stop new scans |
Secret file
Save /srv/myrikeep/secrets/M365_MAIN, replacing these fake values locally:
{
"tenant_id": "11111111-1111-1111-1111-111111111111",
"client_id": "22222222-2222-2222-2222-222222222222",
"client_secret": "<CLIENT_SECRET_VALUE>"
}
Exactly these three nonempty string fields are accepted. Merge the catalog entry below. Include only the types you use; a credential can serve all three:
{"version": 1, "credentials": {"M365_MAIN": {"types": ["m365_mail", "m365_drive", "m365_sharepoint"], "source": {"kind": "file_json", "path": "/run/secrets/M365_MAIN"}}}}
Follow Agent credentials for modes and mounts. Rotate the client secret on the host before expiry. Access tokens are held in agent memory, not uploaded to the console.
Scope, exclusions and schedules
The explicit mailbox list, drive owner or site/library is the scope. Root path
must remain inside the chosen drive. In Connections → View/edit, globs such
as *.tmp and ~$* exclude drive filenames. Drive exclusions see the item name,
not a full folder hierarchy. Mail exclusions see slash-joined mailbox, message,
part and filename fields; *.pdf excludes PDF attachments, not their message
body. Excluding mail parts does not prevent bounded provider enumeration reads.
See Getting started for cadence and windows.
"Who can see it" support
OneDrive and SharePoint inspect configured sharing permissions for anonymous, organization and external grants. Microsoft Graph may return only permissions visible to the app, so results remain partial. An empty permission list is unknown, never proof of restriction. The agent does not expand directory or group membership. Mail sharing checks are not available for this source yet. Drive modification time and mail receipt time support age review. See Who can see it.
Troubleshooting
| State or error | What to do |
|---|---|
unknown |
Wait for current-revision presence; check assignment and agent online status. |
missing / credential_missing |
Check alias, allowed catalog types and mount. |
Invalid / credential_config_invalid |
Check exact JSON keys, tenant/client ID shape and file permissions. |
present |
Local validation passed; consent, secret expiry and resource access still need a scan. |
source_error / 401 / invalid_client |
Inspect local agent diagnostics; check tenant, client ID, secret value and expiry. |
| AccessDenied / 403 | Check Exchange RBAC scope, Graph admin consent or explicit selected-site read grant. Do not add write permissions. |
| 404 / item gone | Verify mailbox/user/site/library IDs and relative root; OneDrive may need provisioning. |
access_denied sharing / partial permissions |
Review read-only metadata permission; preserve unknown if Graph cannot provide complete evidence. |
| 429 / 503 / rate_limited | The agent retries within bounds; narrow scope or spread schedules if failures persist. |
| Paused / Migration paused / Disabled | Resume agent, assign and save a valid migrated connection, or enable it. |
signin_required |
Applies to personal drives. These M365 types use app-only credentials. |
Limits
No sending, writes, directory enumeration, group expansion or general site crawl.
Mail bodies are capped at 20,000 characters; file attachments default to 10 MiB,
with at most 100 attachments per message. Embedded itemAttachment and linked
referenceAttachment are skipped. Mail enumeration is capped at 100,000
messages. Drive walks cap at one million items, 100,000 folders and depth 64;
package and cross-drive items are skipped. Sampling can be narrower. Common
text, PDF text and modern Office have parsers; other files use strings-only
checks. Text in images and scanned PDFs needs OCR, an optional premium feature
a workspace owner enables; it runs inside your agent with the OCR agent image.
Review Coverage and the dated sharing evidence.