ワンクリックで
m365-shared
M365 CLI: Auth, config, global flags, and site/drive discovery. Prerequisite for all m365-* skills.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
M365 CLI: Auth, config, global flags, and site/drive discovery. Prerequisite for all m365-* skills.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Microsoft 365 Mail: Read, send, reply to, and delete email messages; manage mail folders.
SharePoint Docs: Create, co-edit, convert, and share .md/.txt/.docx documents collaboratively in chat.
SharePoint Files: Upload, download, copy, move, rename, delete, and search files in SharePoint document libraries.
SharePoint Lists: Create and manage metadata lists, list items, and columns.
Microsoft 365 Calendar: Create, read, update, and delete events; RSVP to invitations; access shared calendars.
| name | m365-shared |
| version | 0.1.0 |
| description | M365 CLI: Auth, config, global flags, and site/drive discovery. Prerequisite for all m365-* skills. |
| metadata | {"openclaw":{"category":"productivity","requires":{"bins":["m365"]},"cliHelp":"m365 --help"}} |
Install the CLI:
npm install -g github:zrosenfield/m365-cli
# or from source:
git clone https://github.com/zrosenfield/m365-cli && cd m365-cli && npm install && npm run build && npm link
Verify: m365 --version
m365 supports three auth methods, tried in this order on every command:
SP_CLI_ACCESS_TOKEN env varclientSecret is configuredm365 auth loginDelegated (device code) — recommended, least privilege
The app acts as your signed-in user account. It can only access sites your account can access. No admin consent required.
# .env (no SP_CLI_CLIENT_SECRET)
SP_CLI_TENANT_ID=...
SP_CLI_CLIENT_ID=...
m365 auth login # one-time browser sign-in; token stored in OS keychain
m365 sites list # works, scoped to your account's access
App registration prerequisite: Authentication → Advanced settings → Allow public client flows → Yes (required for device code).
Tokens expire (typically 1 hour access / 90-day refresh). Re-run m365 auth login if you get auth errors.
Sites.Selected — app-only, scoped to specific sites
Best for headless agents. The app has no access until a SharePoint admin explicitly grants it per-site. Requires a client secret; no interactive login.
# .env
SP_CLI_TENANT_ID=...
SP_CLI_CLIENT_ID=...
SP_CLI_CLIENT_SECRET=...
m365 sites list # works only for sites the admin has granted
Admin grants access once per site via Graph API (see README App Registration section).
Sites.ReadWrite.All — app-only, full tenant access
Easiest to set up but broadest blast radius. Requires Global/SharePoint Admin consent. Avoid unless you genuinely need tenant-wide access.
m365 auth setup [--tenant-id <id>] [--client-id <id>] [--tenant-url <url>]
m365 auth login # Device code flow; requires tenantId + clientId configured
m365 auth logout # Delete stored keychain token
m365 auth token # Print current access token; --raw for bare string
Config is stored at ~/.m365-cli/config.json (mode 0600).
m365 config set [--tenant <url>] [--site <siteId>] [--drive <driveId>] [--tenant-id <id>] [--client-id <id>]
m365 config get
Keys:
| Key | Description |
|---|---|
tenantId | Azure AD tenant GUID or domain |
clientId | App registration client ID |
clientSecret | Client secret (omit for device code) |
tenantUrl | Default SharePoint URL (e.g. https://contoso.sharepoint.com) |
defaultSiteId | Default site ID used when --site is omitted |
defaultDriveId | Default drive ID used when --drive is omitted |
Most commands accept --site and --drive flags that override config defaults:
--site, --drive, --tenant)defaultSiteId, defaultDriveId, tenantUrl)All commands output JSON to stdout:
{ "data": <result> }
Errors go to stderr:
{ "error": { "code": "...", "message": "...", "status": 404 } }
Use --raw (on m365 auth token) or pipe through jq .data to extract values.
Before using file or list commands, discover the IDs you need:
# List all sites in tenant
m365 sites list | jq '.data[] | {id, displayName, webUrl}'
# Get root site
m365 sites get | jq '.data.id'
# Get site by URL
m365 sites get --url https://contoso.sharepoint.com/sites/mysite
# List drives (document libraries) in a site
m365 drives list --site <site-id> | jq '.data[] | {id, name}'
# Save defaults to avoid repeating flags
m365 config set --site <site-id> --drive <drive-id>
Delegated (device code) — no admin consent needed:
Sites.ReadWrite.All (delegated) — covers lists and list items tooFiles.ReadWrite.All (delegated)Mail.ReadWrite (delegated)Mail.Send (delegated)Calendars.ReadWrite (delegated)Calendars.ReadWrite.Shared (delegated)offline_access (delegated)Sites.Selected — app-only, scoped:
Sites.Selected (application) — admin consents this, then grants per-site via Graph APISites.ReadWrite.All — app-only, full tenant:
Sites.ReadWrite.All (application) — requires Global/SharePoint Admin consentFiles.ReadWrite.All (application)Lists.ReadWrite.All (application)m365 auth token --raw | ... and pipe directly).~/.m365-cli/config.json.m365 auth setup rather than being placed in environment variables in scripts that get committed.