配置 Outlook/Microsoft 365 OAuth 认证
本指南将引导您创建用于 Outlook/Microsoft 365 OAuth 认证的 Microsoft Azure 应用。OAuth 相比传统密码认证更安全。
前置条件
- Microsoft 账户(个人或 Microsoft 365/Office 365)
- 可访问 Azure Portal
- Perfex CRM 安装 URL(用于配置 redirect URI)
信息
对于 Microsoft 365 组织,可能需要管理员批准。
分步配置
步骤 1:在 Azure Portal 注册应用
- 访问 Azure Portal
- 使用 Microsoft 账户登录
- 进入 "Azure Active Directory"(或搜索)
- 在左侧菜单点击 "App registrations"
- 点击 "+ New registration"
- 填写应用信息:
- Name:输入名称(如 "Perfex CRM Mailbox")
- Supported account types:选择 "Accounts in any organizational directory and personal Microsoft accounts" 以获得最大兼容性
- Redirect URI:
- Platform:Web
- URI:
https://your-domain.com/admin/mailbox/oauth/callback?provider=outlook - 将
your-domain.com替换为实际 Perfex CRM 域名
- 点击 "Register"
步骤 2:配置 API 权限
- 在应用注册中,点击左侧 "API permissions"
- 点击 "+ Add a permission"
- 选择 "Microsoft Graph"
- 选择 "Delegated permissions"
- 添加以下权限:
Mail.Read- 读取所有邮箱中的邮件Mail.ReadWrite- 读取和写入所有邮箱中的邮件Mail.Send- 以用户身份发送邮件offline_access- 保持对已授权数据的访问(用于 token 刷新)
- 点击 "Add permissions"
- 重要:若看到 "Grant admin consent for [Your Organization]" 按钮,请点击
注意
组织账户需要此步骤,且需管理员权限。
步骤 3:创建 Client Secret
- 在应用注册中,点击左侧 "Certificates & secrets"
- 点击 "+ New client secret"
- 输入描述(如 "Perfex Mailbox Secret")
- 选择有效期:24 个月(生产环境推荐)
- 点击 "Add"
- 重要:立即复制 Value(之后无法再次查看),即 Client Secret
步骤 4:获取 Application (Client) ID
- 在应用注册中进入 "Overview"
- 复制 Application (client) ID,即 Client ID
步骤 5:验证 Redirect URI
- 在应用注册中,点击左侧 "Authentication"
- 在 "Redirect URIs" 下确认 redirect URI 已列出:
https://your-domain.com/admin/mailbox/oauth/callback?provider=outlook
- 若未列出,点击 "+ Add a platform" > "Web" 并添加
- 在 "Implicit grant and hybrid flows" 下,确保勾选 "Access tokens"(如有)
- 点击 "Save"
步骤 6:在 Perfex CRM 中配置
- 进入 Perfex CRM 管理后台
- 进入 Mailbox > Configuration
- 选择 "OAuth2" 认证方式
- 选择 "Outlook" 提供商
- 输入 Client ID