accessToken method
A valid access JWT (refreshed when it expires within skew) — pass CloudCredentials(account.accessToken) to
a media-server client. Throws UnauthorizedException when signed out.
Implementation
Future<String> accessToken({
Duration skew = const Duration(seconds: 30),
}) async {
final s = _session;
if (s == null) {
throw const UnauthorizedException('not signed in to the cloud');
}
final exp = s.expiresAt;
if (exp != null && clock.now().add(skew).isAfter(exp)) {
if (!await refresh()) {
throw const UnauthorizedException('cloud session expired');
}
}
return _session!.accessToken;
}