init method

Future init([
  1. bool migrateFromHive = true
])

Initializes the auth handler and restores any previously stored tokens.

If migrateFromHive is true, attempts to migrate tokens from legacy Hive storage. After initialization, if a valid JWT exists in storage, it will be set to the Authorization header automatically.

Implementation

Future init([bool migrateFromHive = true]) async {
  await _storage.init(migrateFromHive);

  if (migrateFromHive) {
    await _migrateTokens();
  }

  if (loggingOptions.logStorage) {
    await _storage.log();
  }

  final currentJwt = await jwt;
  if (currentJwt != null && currentJwt.isNotEmpty) {
    _setJwtToHeader(currentJwt);
  }
}