Scan Exchange Online mailboxes, a OneDrive for Business or a SharePoint document library, read-only, from your own agent.
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 |
- Sign-in: app-only Microsoft Graph authentication. No interactive user sign-in is needed.
- Status: these connections are marked Pilot in the console.
What you need
| Requirement | Details |
|---|---|
| Agent | A customer-run agent |
| Network | HTTPS to login.microsoftonline.com, graph.microsoft.com and permitted download hosts |
| People | An Entra administrator to register and authorize an app; for mail, also an Exchange administrator |
| Secrets | Stay on your agent |
Note: 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 the redirect URI blank.
- From Overview, record the Application (client) ID and the Directory (tenant) ID.
- Open Certificates & secrets → Client secrets → New client secret. Choose an expiry your team can maintain.
- Copy the Value once; it is shown only then. The Secret ID is not the credential. Set a rotation reminder before expiry.
Step 2: Grant read access for your chosen source
Grant only what the source you scan needs:
| Source | Permission | How it is limited |
|---|---|---|
| Exchange Online mail | Application Mail.Read through Exchange Application RBAC |
A management scope that matches only tagged mailboxes |
| OneDrive for Business | Graph application permission Files.Read.All |
Not limited: broad file access across the tenant |
| SharePoint document library | Graph application permission Sites.Selected |
An explicit read grant on one site |
Never add write or directory permissions.
Exchange Online mail
As an Exchange admin, install and 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.
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]
This example uses an unused mailbox custom attribute. Agree the attribute with your Exchange admin before setting it.
- Tag only the intended mailboxes.
- Test one mailbox inside and one outside the scope.
- Allow propagation time before a real scan.
Warning: Remove any separately granted Entra Mail.Read application permission. Grants are additive, and the RBAC test excludes Entra permissions.
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. 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.
- For a SharePoint-only app, avoid
Files.Read.AllorSites.Read.All: they would broaden access beyond the selected-site grant.
See Selected permissions.
Step 3: Find scope IDs and add the connection
| Source | Scope value |
|---|---|
| Mailbox email addresses | |
| OneDrive | The user's UPN or object ID |
| SharePoint | Site ID and Drive (library) ID, looked up below |
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 matching Microsoft 365 type.
- Enter its scope, assign the agent and choose Local credential catalog.
- Prepare the secret file 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 synthetic 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; one 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"}}}}
- Modes and mounts: follow Agent credentials.
- Rotation: rotate the client secret on the host before it expires.
- Access tokens: held in agent memory, never uploaded to the console.
Scope, exclusions and schedules
The explicit mailbox list, drive owner or site/library is the scope. The root path must stay inside the chosen drive. Set exclusions in Connections → View/edit.
| Source | What a glob matches | Example |
|---|---|---|
| OneDrive, SharePoint | The item name only, not the full folder hierarchy | *.tmp, ~$* |
| Slash-joined mailbox, message, part and filename fields | *.pdf skips PDF attachments, not the message body |
Excluding mail parts does not prevent bounded provider enumeration reads. See Getting started for cadence and windows.
"Who can see it" support
| Source | Sharing checks | Age signal |
|---|---|---|
| OneDrive, SharePoint | Anonymous, organization and external grants | Modification time |
| Not available for this source yet | Receipt time |
- 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.
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
What it never does: send mail, write, enumerate the directory, expand groups or crawl sites in general.
| Limit | Value |
|---|---|
| Mail body text | 20,000 characters |
| File attachment size | 10 MiB by default |
| Attachments per message | 100 |
| Messages enumerated | 100,000 |
| Drive items | 1,000,000 |
| Drive folders | 100,000 |
| Drive depth | 64 |
Sampling can be narrower than these caps. Review Coverage and the dated sharing evidence after each scan.
Skipped items and file formats
- Embedded
itemAttachmentand linkedreferenceAttachmentare skipped. - Package and cross-drive items are skipped.
- 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.