微软OAuth2认证API网关文档

简化OAuth2认证流程,专注于业务逻辑

欢迎访问微软Oauth2认证接口的前端&文档界面,本项目基于Vercel云平台,将微软OAuth2认证流程封装成简洁高效的API接口,开发者只需通过Post/Get简单调用本接口即可实现安全可靠的收发件功能,无需关心底层认证细节,使得开发者可以专注于业务逻辑开发,而将复杂的OAuth2验证流程托管给本轻量级接口服务。

本接口的特点:

Serverless架构

自动扩展、全球边缘网络加速,降低您的收发件成本,提高收发件效率。

支持 Graph API 取件

会自动判断是否是Graph API,自适应渲染HTML/text内容。

多线程处理

嵌入优化的多线程处理机制,显著提升批量收件效率,可轻松支持高并发场景。

服务可用性SLA

基于Vercel云平台,无需维护基本可超长时间高SLA稳定运行。

请求格式简单

Post/Get本接口即可调用,搭配本店定制调用WebUI可实现批量导入导出、数据托管D1数据库、一键收发件,也可将其集成到注册机脚本中,满足您的个性化需求。

永久超低成本收发件

Serverless架构显著降低了本服务的运行维护成本,事实上,初始接口自研发至今,在基本不维护的情况下已稳定运行两年。

后续更新:

即将推出

纯本地Oauth2接口收发件(即数据和接口都运行在本地)

即将推出

Gmail、QQ邮箱的收发(IMAP邮箱)

即将推出

WebUI端批量收发(目前只有API端可批量收发)

即将推出

本地批量收发(相当于买断制的心蓝,只需一次付费永久可用,无需每年高价订阅心蓝)

以上更新完成后都会在闲鱼店上新,感兴趣的话请关注本店。

📌 我的闲鱼店:七号楼长: 👉点击此处👈

(网页端不支持直接访问店铺,请扫码跳转移动端哦!)

获取最新一封邮件

GET/POST /api/mail-new

获取最新的一封邮件。如果邮件中含有 6 位数字验证码,会自动提取。

参数说明

参数名 必填 描述
refresh_token 必填 用于身份验证的 refresh_token
client_id 必填 客户端 ID
email 必填 邮箱地址
mailbox 必填 邮箱文件夹,支持的值为 `INBOX` 或 `Junk`
response_type 可选 返回格式,支持的值为 `json` 或 `html`,默认为 `json`
password 可选 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问

使用示例

fetch('https://yourdomain.com/api/mail-new?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com&mailbox=INBOX&response_type=json')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
fetch('https://yourdomain.com/api/mail-new', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    refresh_token: 'your_refresh_token',
    client_id: 'your_client_id',
    email: 'your_email@example.com',
    mailbox: 'INBOX',
    response_type: 'json'
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

获取全部邮件

GET/POST /api/mail-all

获取全部邮件。如果邮件中含有 6 位数字验证码,会自动提取。

参数说明

参数名 必填 描述
refresh_token 必填 用于身份验证的 refresh_token
client_id 必填 客户端 ID
email 必填 邮箱地址
mailbox 必填 邮箱文件夹,支持的值为 `INBOX` 或 `Junk`
password 可选 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问

使用示例

fetch('https://yourdomain.com/api/mail-all?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com&mailbox=INBOX')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
fetch('https://yourdomain.com/api/mail-all', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    refresh_token: 'your_refresh_token',
    client_id: 'your_client_id',
    email: 'your_email@example.com',
    mailbox: 'INBOX'
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

清空收件箱

GET/POST /api/process-inbox

清空收件箱。

参数说明

参数名 必填 描述
refresh_token 必填 用于身份验证的 refresh_token
client_id 必填 客户端 ID
email 必填 邮箱地址
password 可选 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问

使用示例

fetch('https://yourdomain.com/api/process-inbox?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
fetch('https://yourdomain.com/api/process-inbox', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    refresh_token: 'your_refresh_token',
    client_id: 'your_client_id',
    email: 'your_email@example.com'
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

清空垃圾箱

GET/POST /api/process-junk

清空垃圾箱。

参数说明

参数名 必填 描述
refresh_token 必填 用于身份验证的 refresh_token
client_id 必填 客户端 ID
email 必填 邮箱地址
password 可选 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问

使用示例

fetch('https://yourdomain.com/api/process-junk?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
fetch('https://yourdomain.com/api/process-junk', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    refresh_token: 'your_refresh_token',
    client_id: 'your_client_id',
    email: 'your_email@example.com'
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

发送邮件

GET/POST /api/send-mail

发送邮件。支持纯文本(`text`)或 HTML 格式(`html`)的内容。

参数说明

参数名 必填 描述
refresh_token 必填 用于身份验证的 refresh_token
client_id 必填 客户端 ID
email 必填 发件人邮箱地址
to 必填 收件人邮箱地址
subject 必填 邮件主题
text 可选 邮件的纯文本内容(与 `html` 二选一)
html 可选 邮件的 HTML 内容(与 `text` 二选一)
send_password 可选 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 SEND_PASSWORD 来启用此功能。启用后,请求时需提供正确的 SEND_PASSWORD 参数方可访问

使用示例

fetch('https://yourdomain.com/api/send-mail?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com&to=recipient@example.com&subject=Hello&text=This is a test email')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
fetch('https://yourdomain.com/api/send-mail', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    refresh_token: 'your_refresh_token',
    client_id: 'your_client_id',
    email: 'your_email@example.com',
    to: 'recipient@example.com',
    subject: 'Hello',
    text: 'This is a test email',
    // 或者使用 html: '

This is a test email

' }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));

© 2025 微软OAuth2认证API网关文档