Premier commit

This commit is contained in:
2026-09-11 14:55:41 +02:00
commit 8ed04aae89
134 changed files with 36627 additions and 0 deletions
@@ -0,0 +1,22 @@
using Azure.Identity;
using Microsoft.Extensions.Options;
using Microsoft.Graph;
namespace SIFinance.Api;
// Construit le GraphServiceClient à la demande plutôt qu'au démarrage : tant que les
// identifiants SharePoint (TenantId/ClientId/ClientSecret) ne sont pas renseignés,
// ClientSecretCredential lève une exception à la construction — on veut que ça arrive
// à l'intérieur du try/catch de l'endpoint qui l'appelle, pas pendant la résolution DI.
public class SharePointGraphClientFactory(IOptions<SharePointOptions> options)
{
public GraphServiceClient Create()
{
var opts = options.Value;
if (string.IsNullOrWhiteSpace(opts.TenantId) || string.IsNullOrWhiteSpace(opts.ClientId) || string.IsNullOrWhiteSpace(opts.ClientSecret))
throw new InvalidOperationException("Configuration SharePoint incomplète (TenantId/ClientId/ClientSecret) — voir SIFinance.Api/appsettings.Development.json.");
var credential = new ClientSecretCredential(opts.TenantId, opts.ClientId, opts.ClientSecret);
return new GraphServiceClient(credential, ["https://graph.microsoft.com/.default"]);
}
}