Skip to content
Bitzsoft.Integrationsbitzsoft.integrations

Reference

Microsoft 365 Calendar

Bitzsoft.Integrations.Calendar.Microsoft365 包参考——Azure AD Bearer(Microsoft Graph)鉴权、ICalendarService 配置与使用示例。

Last updated

Microsoft 365 Calendar 基于 Microsoft Graph API,实现 ICalendarService 统一接口。

包信息

NuGet 包Bitzsoft.Integrations.Calendar.Microsoft365
实现接口ICalendarService
Provider IDmicrosoft-365
鉴权方式Azure AD Client Credentials 模式获取的 Bearer Access Token,注入 Authorization: Bearer {token}
默认 BaseUrlhttps://graph.microsoft.com/v1.0
区域Global

本实现直接接收已获取的 Access Token,适用于令牌由外部 Token 管理器统一刷新的场景。

配置字段

字段类型必填默认值说明
AccessTokenstringAzure AD Bearer Access Token
BaseUrlstringhttps://graph.microsoft.com/v1.0Microsoft Graph API 基地址
UserOrUpnstring?目标用户 ID 或 UPN(如 user@tenant.com);留空则使用 /me 端点(需 Delegated 令牌)
HttpClientNamestringCalendarMicrosoft365业务 HttpClient 命名

配置 JSON 示例

{
"Calendar": {
"Microsoft365": {
"AccessToken": "eyJ0eXAiOiJKV1Qi...",
"BaseUrl": "https://graph.microsoft.com/v1.0",
"UserOrUpn": "user@tenant.com"
}
}
}

DI 注册

// 从配置节注册(默认节名 Calendar:Microsoft365)
services.AddMicrosoft365Calendar(configuration);
// 或用回调单独配置
services.AddMicrosoft365Calendar(options =>
{
options.AccessToken = "eyJ0eXAiOiJKV1Qi...";
options.UserOrUpn = "user@tenant.com";
});

使用示例

public class EventService
{
private readonly ICalendarService _calendar;
public EventService(ICalendarService calendar) => _calendar = calendar;
public Task<CalendarEvent> GetAsync(string eventId)
=> _calendar.GetEventAsync(eventId);
public Task<List<CalendarEvent>> ListUpcomingAsync()
=> _calendar.ListEventsAsync(new ListEventsRequest
{
StartAfter = DateTimeOffset.UtcNow
});
public Task<CalendarResult> DeclineAsync(string eventId, string reason)
=> _calendar.DeclineInvitationAsync(eventId, reason);
}

依赖

说明
Bitzsoft.Integrations.Calendar日历服务抽象层
Bitzsoft.Integrations.Core公共基座
Bitzsoft.Integrations.MicrosoftGraphMicrosoft Graph 调用支持

已知限制

  • 本包不内置令牌刷新逻辑,Access Token 须由外部 Token 管理器定期刷新后更新配置。
  • Application 权限模式下必须指定 UserOrUpn

100%

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