logIn method
Authorizes the LoginClient using the passed strategy
.
This method will log the LoginClient out on the authorization failure.
Implementation
Future<void> logIn(AuthorizationStrategy strategy) async {
try {
_oAuthClient = await strategy.execute(
_oAuthSettings,
_httpClient,
_onCredentialsRefreshed,
);
await _credentialsStorage.save(_oAuthClient!.credentials);
_onCredentialsChanged.add(_oAuthClient!.credentials);
_logger('Successfully logged in and saved the credentials.');
} on oauth2.AuthorizationException {
await _logOutInternal();
_logger(
'An error while logging in occured, '
'successfully logged out and cleared credentials.',
);
rethrow;
}
}