Skip to main content
Version: 11.14.0

getJWToken

Sends credentials to the backend to obtain a JSON Web Token (JWT). If a valid CSRF token is returned in the response, it is automatically stored in session storage.

Parameters

ParameterTypeRequiredDescription
credentialsCredentialsUsername and password credentials

Returns Promise<string | null> — the JWT token if authentication succeeded, or null otherwise.

Example

get-jwt-token.ts
import { getJWToken } from '@sinequa/atomic';

const token = await getJWToken({ username: 'user', password: 'pa$$word' });
if (token) {
console.log('JWT token:', token);
} else {
console.log('Authentication failed');
}