configure static method
Configures automatic JWT management via SdkTokenInterceptor.
Call once during SDK initialisation. Any previously registered SdkTokenInterceptor is replaced.
baseUrl: root URL of the TSDTech backendorgId: organisation identifier sent in the token request bodyonSessionExpired: optional callback invoked when the session cannot be renewed (e.g. to navigate the user to a login screen)
Implementation
static void configure({
required String baseUrl,
required String orgId,
void Function()? onSessionExpired,
}) {
_dio.interceptors.removeWhere((i) => i is SdkTokenInterceptor);
_dio.interceptors.add(
SdkTokenInterceptor(
mainDio: _dio,
orgId: orgId,
pixTokenUrl: '$baseUrl/auth/sdk/pix-token',
onSessionExpired: onSessionExpired,
onTokenChanged: (token) {
for (final fn in List.of(_tokenListeners)) {
fn(token);
}
},
),
);
}