login method

Future<void> login()

throws an exception if the TokenResponse from AuthenticatorProvider is null.

Initiates the login process using the authenticator provider. Stores the accessToken and user name locally using storage provider

Implementation

Future<void> login() async {
  await _authenticatorProvider.authorize();

  final TokenResponse? tokenResponse =
      await _authenticatorProvider.getTokenResponse();
  if (tokenResponse == null) {
    throw 'TokenResponse from AuthenticatorProvider is null. Check if the Credentials is created or not';
  }

  await _storageProvider.setTokenResponse(_toEncodedString(tokenResponse));

  final String? userName = _authenticatorProvider.getUserName();
  await _storageProvider.setUserName(userName);

  _authenticatorProvider.close();
}