authenticate method

Future<void> authenticate(
  1. Map<String, String> metadata,
  2. String uri
)
inherited

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((_) {});
  }
}