Skip to content
Bitzsoft.Integrationsbitzsoft.integrations

Reference

Microsoft Teams VideoConference

Microsoft Teams 视频会议服务——Azure AD Client Credentials 调 Graph onlineMeetings API。

Last updated

基于 Microsoft Graph onlineMeetings API 实现,采用 Azure AD Client Credentials 令牌模式,内置令牌缓存与自动刷新。

包信息

  • NuGet 包:Bitzsoft.Integrations.VideoConference.MicrosoftTeams
  • 接口:IVideoConferenceService
  • 鉴权:Azure AD Client Credentials(TenantId / ClientId / ClientSecret)
  • Provider ID:microsoft-teams

配置

字段类型必填默认值说明
TenantIdstring租户 ID(Tenant / Directory ID)
ClientIdstring应用(客户端)ID
ClientSecretstring应用密钥(Client Secret)
DefaultUserPrincipalNamestring默认会议组织者的 UPN(Graph app-only 模式必填)
BaseUrlstringhttps://graph.microsoft.comMicrosoft Graph REST API 基地址
OAuthBaseUrlstringhttps://login.microsoftonline.comAzure AD OAuth2 令牌端点基地址
HttpClientNamestringVideoConferenceMicrosoftTeams业务 HttpClient 命名
TokenHttpClientNamestringVideoConferenceMicrosoftTeamsToken令牌刷新专用 HttpClient 命名
{
"VideoConference": {
"MicrosoftTeams": {
"TenantId": "your-tenant-id",
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret",
"DefaultUserPrincipalName": "organizer@contoso.com"
}
}
}

注册

// 方式一:IConfiguration(默认读取 "VideoConference:MicrosoftTeams" 配置节)
services.AddMicrosoftTeamsVideoConference(configuration);
// 方式二:委托配置
services.AddMicrosoftTeamsVideoConference(options =>
{
options.TenantId = "your-tenant-id";
options.ClientId = "your-client-id";
options.ClientSecret = "your-client-secret";
options.DefaultUserPrincipalName = "organizer@contoso.com";
});

使用示例

var meeting = await service.CreateMeetingAsync(new CreateMeetingRequest
{
Subject = "Quarterly Review",
StartTime = DateTimeOffset.Parse("2026-08-05T09:00:00Z"),
EndTime = DateTimeOffset.Parse("2026-08-05T10:00:00Z"),
Attendees = [new() { Email = "team@contoso.com" }]
});
// 取消会议
await service.CancelMeetingAsync(meeting.MeetingId);

鉴权机制

  • 令牌获取:POST /{tenant}/oauth2/v2.0/token,form-urlencoded,grant_type=client_credentialsscope=https://graph.microsoft.com/.default
  • 令牌缓存:MicrosoftTeamsTokenManager 为 Singleton,过期前 5 分钟刷新。
  • 业务请求:按请求注入 Authorization: Bearer {token} 头。
  • HTTP 401 Unauthorized 触发令牌失效自愈。

已知限制

Graph onlineMeetings API 在 app-only 模式下不支持 /users/me,必须指定 OrganizerUserId(UPN 或 objectId),或在配置中设置 DefaultUserPrincipalName,否则抛 VideoConferenceException

100%

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