login method

  1. @override
Future<void> login()
override

throws an exception if the TokenResponse from AuthenticatorProvider is null.

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

Implementation

@override
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? userInfo = _authenticatorProvider.getUserInfo();
  if (userInfo != null) {
    await _storageProvider.setUserInfo(userInfo);
  }

  _authenticatorProvider.close();
}