Namespace SESARWebHook.Core.Auth
Classes
- OAuth2ClientCredentialsHelper
Helper pour l'authentification OAuth 2.0 Client Credentials.
Utilisé pour les APIs qui supportent le flow "client credentials" :
- Microsoft Azure AD (SharePoint, Dynamics 365, Graph API)
- Google Cloud (avec service account)
- AWS Cognito
- Okta
FONCTIONNALITÉS :
- Obtention automatique du token
- Cache du token en mémoire
- Refresh automatique avant expiration
- Thread-safe
EXEMPLE D'UTILISATION :
var auth = new OAuth2ClientCredentialsHelper( tokenEndpoint: "https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token", clientId: "your-client-id", clientSecret: "your-client-secret", scope: "https://graph.microsoft.com/.default" ); var token = await auth.GetAccessTokenAsync(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- OAuth2Exception
Exception levée lors d'une erreur d'authentification OAuth2.
- OAuth2RefreshTokenHelper
Helper pour l'authentification OAuth 2.0 avec Refresh Token.
Utilisé pour les APIs qui nécessitent un refresh token initial :
- Zoho CRM, Books, etc.
- Google APIs (Gmail, Drive, etc.)
- Salesforce
- HubSpot
FONCTIONNALITÉS :
- Obtention automatique du token via refresh token
- Cache du token en mémoire
- Refresh automatique avant expiration
- Thread-safe
- Support pour différents formats de réponse
EXEMPLE D'UTILISATION :
var auth = new OAuth2RefreshTokenHelper( tokenEndpoint: "https://accounts.zoho.com/oauth/v2/token", clientId: "your-client-id", clientSecret: "your-client-secret", refreshToken: "your-refresh-token" ); var token = await auth.GetAccessTokenAsync(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);