authenticate method
Implementation
Future<void> authenticate(Map<String, String> metadata, String uri) async {
if (_accessToken == null ||
_accessToken!.hasExpired ||
!_lastUriSet ||
uri != _lastUri) {
await obtainAccessCredentials(uri);
_lastUri = uri;
_lastUriSet = true;
}
final auth = '${_accessToken!.type} ${_accessToken!.data}';
metadata['authorization'] = auth;
if (_tokenExpiresSoon) {
// Token is about to expire. Extend it prematurely.
obtainAccessCredentials(_lastUri).catchError((_) {});
}
}