JWT Authentication Flow
1. User Login
If you already have an account created you can authenticate with email and password to receive JWT tokens:DT_AUTH_TOKEN: Access token (1 hour expiry)DT_REFRESH_TOKEN: Refresh token (30 days expiry)
JWT authentication for front end applications.
curl -X POST https://api.finvera.news/kms/api/v1/auth/token \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "your_password"
}'
{
"message": "Authentication successful",
"expires_in": 3600
}
DT_AUTH_TOKEN: Access token (1 hour expiry)DT_REFRESH_TOKEN: Refresh token (30 days expiry)curl -X POST https://api.finvera.news/kms/api/v1/auth/refresh \
-H "Cookie: DT_REFRESH_TOKEN=your_refresh_token"
{
"message": "Token refreshed successfully",
"expires_in": 3600
}
curl -X GET https://api.finvera.news/kms/api/v1/auth/validate \
-H "Authorization: Bearer your_access_token"
{
"user_id": "uuid",
"email": "[email protected]",
"username": "user123",
"licensing_tier_id": "enterprise"
}
// Authentication service
class AuthService {
async login(email, password) {
const response = await fetch('/api/v1/auth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }),
credentials: 'include' // Include cookies
});
if (!response.ok) {
throw new Error('Authentication failed');
}
return response.json();
}
async makeAuthenticatedRequest(url, options = {}) {
return fetch(url, {
...options,
credentials: 'include', // Include auth cookies
headers: {
...options.headers,
'Content-Type': 'application/json'
}
});
}
}
import requests
from datetime import datetime, timedelta
class FinveraClient:
def __init__(self, base_url="https://api.finvera.news"):
self.base_url = base_url
self.access_token = None
self.refresh_token = None
self.token_expires_at = None
def login(self, email, password):
response = requests.post(
f"{self.base_url}/kms/api/v1/auth/token",
json={"email": email, "password": password}
)
response.raise_for_status()
data = response.json()
self.access_token = data.get("token")
self.refresh_token = data.get("refresh_token")
self.token_expires_at = datetime.now() + timedelta(seconds=data.get("expires_in", 3600))
def make_request(self, endpoint, **kwargs):
if self._token_expired():
self._refresh_token()
headers = kwargs.get("headers", {})
headers["Authorization"] = f"Bearer {self.access_token}"
kwargs["headers"] = headers
return requests.get(f"{self.base_url}{endpoint}", **kwargs)