← 返回 Skills 市场
fredguile

Outlook Entra

作者 Fred Ghilini · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
28
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install outlook-entra
功能描述
Microsoft Outlook via OAuth 2.0 (device code flow) et Microsoft Graph API. Lecture seule — Mail.Read, Calendars.Read, Contacts.Read.
使用说明 (SKILL.md)

Outlook Entra — SKILL.md

Microsoft Outlook via OAuth 2.0 (device code flow) et Microsoft Graph API. Lecture seule — seules les permissions Mail.Read, Calendars.Read, Contacts.Read sont utilisées.

Prérequis

  • App enregistrée sur Entra (Azure AD) avec permissions :
    • Mail.Read, Calendars.Read, Contacts.Read
    • OAuth 2.0 device code flow activé
  • Python 3.8+ avec requests, html2text, cryptography
  • Python 3.8+ avec un .venv créé dans le répertoire du skill (uv venv .venv && uv pip install html2text requests cryptography)
  • Fichier .env configuré (voir .env.example)

Installation

# Créer l'environnement virtuel (obligatoire)
cd ~/.openclaw/workspace/skills/outlook-entra
uv venv .venv
uv pip install html2text requests cryptography

# Copier et éditer la config
cp .env.example .env
# ⚠️ Remplir client_id, client_secret, tenant_id dans .env

Authentification (Flow)

Le device code flow (RFC 8628) nécessite une intervention utilisateur unique.

Étape 1 — Lancer le script d'auth

.venv/bin/python scripts/outlook_auth.py

Le script va :

  1. Demander un device code à Microsoft
  2. Afficher un code utilisateur et une URL de vérification

Étape 2 — S'authentifier

Aller sur https://login.microsoft.com/device et entrer le code affiché. Délai : 15 minutes maximum.

Étape 3 — Attendre la confirmation

Le script poll automatiquement le endpoint Microsoft jusqu'à obtention du token. Une fois confirmé, les tokens sont sauvegardés localement.

Fonctionnement des tokens

  • L'access_token expire après ~1h
  • Le refresh_token permet d'obtenir un nouvel access_token sans intervention
  • Le refresh est automatisé par cron toutes les heures (voir section Cron)
  • Si le refresh_token expire aussi (plusieurs mois d'inactivité) → relancer le flow complet

Commandes utiles

# Vérifier le statut du token
.venv/bin/python scripts/outlook_auth.py --status

# Rafraîchir le token manuellement
.venv/bin/python scripts/outlook_refresh.py

# Révoquer et supprimer les tokens
.venv/bin/python scripts/outlook_auth.py --revoke

Commandes (lecture seule)

# Statut de connexion
.venv/bin/python scripts/outlook_auth.py --status

# Lire les derniers messages
.venv/bin/python scripts/outlook_graph.py messages --folder Inbox --top 10

# Détail d'un message (corps complet, Markdown par défaut)
.venv/bin/python scripts/outlook_graph.py message \x3CmessageId>

# Détail en HTML brut (pour extraction/collage)
.venv/bin/python scripts/outlook_graph.py message \x3CmessageId> --raw

# Lister les dossiers mail
.venv/bin/python scripts/outlook_graph.py folders

# Pièces jointes d'un message
.venv/bin/python scripts/outlook_graph.py attachments \x3CmessageId>

# Télécharger une pièce jointe
.venv/bin/python scripts/outlook_graph.py download \x3CmessageId> --attach-id \x3CattachmentId> --output /path/to/file

# Événements calendrier
.venv/bin/python scripts/outlook_graph.py events --top 10

# Contacts
.venv/bin/python scripts/outlook_graph.py contacts --top 20

# Rechercher dans les mails
.venv/bin/python scripts/outlook_graph.py search "mot-clé"

# Profil utilisateur
.venv/bin/python scripts/outlook_graph.py profile

Variables d'environnement (.env)

Variable Description Exemple
AZURE_TENANT_ID GUID du tenant Entra 52ffb8b9-…
AZURE_CLIENT_ID ID de l'app (Application ID) xxxxxxxx-…
AZURE_CLIENT_SECRET Secret de l'app ~
AZURE_REDIRECT_URI Redirect URI (device flow : tout fait) http://localhost
OAUTH_TOKEN_URL URL token endpoint https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
OAUTH_DEVICE_CODE_URL URL device code endpoint https://login.microsoftonline.com/{tenant}/oauth2/v2.0/devicecode
MS_GRAPH_BASE_URL Base URL Microsoft Graph https://graph.microsoft.com/v1.0
TOKEN_FILE Chemin du fichier de stockage des tokens ~/.openclaw/outlook_tokens.json
TOKEN_FILE_KEY Clé de chiffrement (optionnel) (vide par défaut)

Structure du skill

outlook-entra/
├── SKILL.md
├── README.md
├── .env.example
├── .gitignore
├── .venv/                   # Environnement virtuel Python (créé via uv venv)
├── scripts/
│   ├── outlook_auth.py      # OAuth device code flow + status/revoke
│   ├── outlook_graph.py     # Appels Graph API (lecture seule)
│   ├── outlook_refresh.py   # Refresh token automatisé (pour cron)
│   └── outlook_token.py     # Module partagé (lecture/refresh tokens)
└── tests/
    └── test_outlook.py      # Tests unitaires

Notes

  • Le device code flow (RFC 8628) : l'utilisateur authentifie via https://microsoft.com/devicelogin. Une seule fois.
  • Les refresh tokens sont automatiquement utilisés quand l'access token expire.
  • Si TOKEN_FILE_KEY est défini, les tokens sont chiffrés AES-GCM avant stockage.
  • Les erreurs 401 du Graph API déclenchent un refresh automatique.

Cron — Refresh automatique du token

Le script outlook_refresh.py vérifie si le token expire bientôt et le rafraîchit automatiquement.

Crontab — refresh toutes les heures à HH:55 :

55 * * * * /home/fred-ghilini/.openclaw/workspace/skills/outlook-entra/.venv/bin/python /home/fred-ghilini/.openclaw/workspace/skills/outlook-entra/scripts/outlook_refresh.py >> /home/fred-ghilini/.openclaw/outlook_refresh.log 2>&1

Installation :

SKILL_DIR="/home/fred-ghilini/.openclaw/workspace/skills/outlook-entra"
( crontab -l 2>/dev/null | grep -v outlook_refresh; echo "55 * * * * ${SKILL_DIR}/.venv/bin/python ${SKILL_DIR}/scripts/outlook_refresh.py >> ~/.openclaw/outlook_refresh.log 2>&1" ) | crontab -

Vérification :

crontab -l | grep outlook_refresh

Ressources

安全使用建议
Install only if you are comfortable granting this skill durable access to Microsoft account data. Use the narrowest Graph scopes possible, set TOKEN_FILE_KEY, protect the token file, avoid the cron job unless you truly need always-on refresh, and download attachments only into a dedicated safe directory.
能力标签
requires-oauth-tokenrequires-sensitive-credentials
能力评估
Purpose & Capability
The core Outlook Graph purpose is coherent, but the documentation emphasizes Mail.Read, Calendars.Read, and Contacts.Read while the code defaults to requesting user.read, openid, profile, and offline_access and includes a profile command. That creates a real mismatch between the stated read-only Outlook scope and actual identity/session access.
Instruction Scope
Most sensitive behaviors are mentioned somewhere, but not consistently: token encryption is described as available yet optional, profile access is not reflected in the declared permissions, and attachment download risks are not explained.
Install Mechanism
Installation is user-directed through a local Python virtual environment and dependencies. The cron setup is explicit rather than automatic, but the provided command installs recurring host-level token refresh.
Credentials
Network access to Microsoft OAuth and Graph, local .env secrets, token file writes, and attachment writes are broadly expected for this integration, but storing refresh tokens locally without mandatory encryption or restrictive permissions is high impact for a mail/calendar/contact skill.
Persistence & Privilege
The skill stores OAuth access and refresh tokens under ~/.openclaw and recommends hourly cron refresh. This is purpose-aligned convenience, but it creates durable session persistence without enough hardening, scoping, or removal guidance.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install outlook-entra
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /outlook-entra 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Outlook Entra 1.0.0 — Initial Release - Secure Microsoft Outlook integration using OAuth 2.0 device code flow and Microsoft Graph API. - Read-only access to mail, calendar, and contacts (`Mail.Read`, `Calendars.Read`, `Contacts.Read`). - Step-by-step authentication guide with token management and refresh (manual or cron). - Python scripts for listing emails, events, contacts, downloading attachments, and checking user profile. - Optional local AES-GCM encryption for token storage. - Example `.env` configuration and automated cron setup included.
元数据
Slug outlook-entra
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Outlook Entra 是什么?

Microsoft Outlook via OAuth 2.0 (device code flow) et Microsoft Graph API. Lecture seule — Mail.Read, Calendars.Read, Contacts.Read. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 28 次。

如何安装 Outlook Entra?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install outlook-entra」即可一键安装,无需额外配置。

Outlook Entra 是免费的吗?

是的,Outlook Entra 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Outlook Entra 支持哪些平台?

Outlook Entra 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Outlook Entra?

由 Fred Ghilini(@fredguile)开发并维护,当前版本 v1.0.0。

💬 留言讨论