initialize method

Future<void> initialize()

Restores saved credentials from the credentials storage.

Implementation

Future<void> initialize() async {
  final credentials = await _credentialsStorage.read();
  if (credentials != null) {
    _oAuthClient = buildOAuth2ClientFromCredentials(
      credentials,
      oAuthSettings: _oAuthSettings,
      httpClient: _httpClient,
      onCredentialsRefreshed: _onCredentialsRefreshed,
    );
  }

  _onCredentialsChanged.add(credentials);

  if (credentials != null) {
    _logger('Successfully initialized with credentials.');
  } else {
    _logger('Successfully initialized with no credentials.');
  }
}