Authentification
Endpoints pour l'authentification et la gestion des sessions.
POST /auth/login
Authentifie un utilisateur et retourne un token JWT.
Request
bash
POST /api/v1/auth/login
Content-Type: application/x-www-form-urlencodedBody
| Champ | Type | Requis | Description |
|---|---|---|---|
| username | string | Oui | Email de l'utilisateur |
| password | string | Oui | Mot de passe |
Exemple
bash
curl -X POST https://api.gbfiscalai.srv1164291.hstgr.cloud/api/v1/auth/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin@gbfiscalai.gw&password=admin123"Response 200
json
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer"
}Response 401
json
{
"detail": "Incorrect email or password"
}GET /auth/me
Retourne les informations de l'utilisateur connecté.
Request
bash
GET /api/v1/auth/me
Authorization: Bearer <token>Exemple
bash
curl https://api.gbfiscalai.srv1164291.hstgr.cloud/api/v1/auth/me \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."Response 200
json
{
"id": 1,
"email": "admin@gbfiscalai.gw",
"full_name": "Administrateur",
"role": "admin",
"is_active": true,
"created_at": "2026-01-01T00:00:00Z"
}Response 401
json
{
"detail": "Could not validate credentials"
}POST /auth/refresh
Rafraîchit un token JWT expirant bientôt.
Request
bash
POST /api/v1/auth/refresh
Authorization: Bearer <token>Response 200
json
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer"
}Token JWT
Structure
Le token contient:
json
{
"sub": "admin@gbfiscalai.gw",
"exp": 1736700000,
"iat": 1736696400
}| Champ | Description |
|---|---|
| sub | Email de l'utilisateur |
| exp | Timestamp d'expiration |
| iat | Timestamp de création |
Durée de Validité
- Token standard: 24 heures
- Après expiration: nouvelle authentification requise
Stockage Recommandé
- Navigateur: localStorage ou sessionStorage
- Mobile: Secure Storage
- Backend: Variable d'environnement
Sécurité
WARNING
Ne jamais exposer le token dans les logs ou URLs.