Skip to content
Bitzsoft.Integrationsbitzsoft.integrations

Reference

飞书 TeamWork

飞书协同办公包的 FeishuOptions 配置字段、tenant_access_token 鉴权、8 个能力接口(含日历+文档)与使用示例。

Last updated

包信息

属性
NuGet 包Bitzsoft.Integrations.TeamWork.Feishu
Provider IDfeishu
鉴权方式tenant_access_token(Bearer Header,AuthHandler 自动刷新)
能力接口Org、Message、Todo、Approval、Sso、Health、Calendar、Document(8 个)

配置字段(FeishuOptions)

字段类型必填默认值说明
AppIdstring应用 App ID
AppSecretstring应用 App Secret
BaseUrlstringhttps://open.feishu.cn飞书开放平台 API 基地址
EncryptKeystring?事件订阅 Encrypt Key
VerificationTokenstring?事件订阅 Verification Token
HttpClientNamestringTeamWorkFeishu业务 HttpClient 命名
TokenHttpClientNamestringTeamWorkFeishuToken令牌刷新专用 HttpClient

配置示例

{
"TeamWork": {
"Feishu": {
"AppId": "cli_xxxxxxx",
"AppSecret": "your-app-secret",
"BaseUrl": "https://open.feishu.cn",
"EncryptKey": "optional-event-encrypt-key",
"VerificationToken": "optional-verification-token"
}
}
}

DI 注册

// ① 配置节绑定
builder.Services.AddBitzsoftFeishuTeamWork(builder.Configuration.GetSection("TeamWork:Feishu"));
// ② 委托配置
builder.Services.AddBitzsoftFeishuTeamWork(options =>
{
options.AppId = "cli_xxxxxxx";
options.AppSecret = "your-app-secret";
});

能力接口方法

飞书实现了与钉钉相同的 Org、Message、Todo、Approval、Sso、Health 六个接口,外加两个独有接口:

ITeamWorkCalendarProvider(飞书独有)

Task<string> CreateEventAsync(CalendarEventRequest request, CancellationToken ct = default);
Task<CalendarEvent?> GetEventAsync(string eventId, CancellationToken ct = default);
Task UpdateEventAsync(string eventId, CalendarEventRequest request, CancellationToken ct = default);
Task DeleteEventAsync(string eventId, CancellationToken ct = default);

ITeamWorkDocumentProvider(飞书独有)

Task<string> CreateDocumentAsync(DocumentCreateRequest request, CancellationToken ct = default);
Task<DocumentInfo> GetDocumentAsync(string documentId, CancellationToken ct = default);
Task<Stream> DownloadDocumentAsync(string documentId, CancellationToken ct = default);

使用示例

// ① 能力探测:日历(飞书有,钉钉没有)
public class CalendarService(ITeamWorkOrgProvider org)
{
public async Task<string?> CreateEventIfSupportedAsync(CalendarEventRequest evt)
{
if (org is ITeamWorkCalendarProvider calendar)
return await calendar.CreateEventAsync(evt);
return null;
}
}
// ② 直接注入飞书独有接口
public class DocService(ITeamWorkDocumentProvider doc)
{
public async Task<string> CreateDocAsync(string title)
{
return await doc.CreateDocumentAsync(new DocumentCreateRequest { Title = title });
}
}

已知限制

  • 飞书不实现 ITeamWorkContactProvider(企业微信独有),注入转型会失败。
  • 日历与文档能力依赖飞书应用的对应权限范围(Calendar、Docs 权限)。

相关

100%

滚轮或按钮缩放 · 放大后拖动画面 · 双击切换 100% / 200%