包信息
| 属性 | 值 |
|---|---|
| NuGet 包 | Bitzsoft.Integrations.CloudDrive.Microsoft365 |
| Provider ID | microsoft365 |
| 协议 | Microsoft Graph(client_credentials) |
配置字段(Microsoft365Options)
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
TenantId | string | 是 | — | Azure AD 租户 ID |
ClientId | string | 是 | — | 应用客户端 ID |
ClientSecret | string | 是 | — | 应用客户端密钥 |
DriveId | string | 是 | — | OneDrive/SharePoint drive ID |
BaseUrl | string | 否 | https://graph.microsoft.com/v1.0 | Graph API 基地址 |
AuthorityUrl | string | 否 | 自动拼接 | 令牌颁发地址 |
HttpClientName | string | 否 | Microsoft365CloudDrive | 旧版兼容字段 |
LargeFileThreshold | long | 否 | 4MB | 上传会话模式阈值(最大 250 MB) |
配置示例
{ "CloudDrive": { "Microsoft365": { "TenantId": "your-tenant-id", "ClientId": "your-client-id", "ClientSecret": "your-client-secret", "DriveId": "b!xxxxxxxxxxxxxxxxxx" } }}DI 注册
builder.Services.AddBitzsoftMicrosoft365CloudDrive(builder.Configuration.GetSection("CloudDrive:Microsoft365"));使用示例
public class GraphDriveService(ICloudDriveProvider drive){ public async Task<DriveShareLink> ShareAsync(string fileId) { return await drive.CreateShareLinkAsync(new CreateShareLinkRequest { FileId = fileId, }); }
public async Task<IReadOnlyList<DriveFileVersion>> VersionsAsync(string fileId) { return await drive.ListVersionsAsync(fileId); }}已知限制
AuthorityUrl留空时根据TenantId自动拼接为https://login.microsoftonline.com/{TenantId}/oauth2/v2.0/token。- 大文件(超过
LargeFileThreshold)使用 Graph 上传会话模式,单请求上限 250 MB。