getBearerToken method
Implementation
Future<String?> getBearerToken(
String? deviceId,
bool forceRefresh
) async {
final tokenFileContent = await AppticsDataStore.getFileContents(FileType.bearerInfo);
if (tokenFileContent == null) {
return await _freshTokenGenerator.getToken();
}
final token = jsonDecode(tokenFileContent)[deviceId];
if (token == null) {
return await _freshTokenGenerator.getToken();
} else {
var interval = DateTime.now().millisecondsSinceEpoch - token["fetchtime"];
if (interval >= 1000 * 60 * 60 && deviceId != null && !forceRefresh) {
return TokenRefresher()._refreshToken(deviceId, token);
} else {
return token["token"];
}
}
}