getToken method
Implementation
Future<String?> getToken() async {
if (await isAuthenticate()) {
return _store.authState?.accessToken;
}
final version = await _getVersion();
final versionParam = 'Flutter/$version';
try {
if (authState?.refreshToken == null) {
throw KindeError("Session expired or invalid");
}
final data = await _tokenApi.retrieveToken(
versionParam,
_store.authState!.createRequestTokenParam()
..putIfAbsent(_clientIdParamName, () => _config!.authClientId));
_store.authState = AuthState.fromJson(data as Map<String, dynamic>);
_kindeApi.setBearerAuth(_bearerAuth, _store.authState?.accessToken ?? '');
return _store.authState?.accessToken;
} on KindeError catch (_) {
rethrow;
} on Exception catch (ex) {
throw handleError(ex);
}
}