loginInteractive method

Future<OpenIdIdentity> loginInteractive({
  1. required BuildContext context,
  2. required String title,
  3. String? userNameHint,
  4. Map<String, String>? additionalParameters,
  5. Iterable<String>? prompts,
  6. bool useWebPopup = true,
  7. int popupWidth = 640,
  8. int popupHeight = 600,
})

Implementation

Future<OpenIdIdentity> loginInteractive({
  required BuildContext context,
  required String title,
  String? userNameHint,
  Map<String, String>? additionalParameters,
  Iterable<String>? prompts,
  bool useWebPopup = true,
  int popupWidth = 640,
  int popupHeight = 600,
}) async {
  if (this.redirectUrl == null)
    throw StateError(
        "When using login interactive, you must create the client with a redirect url.");

  if (_autoRenewTimer != null) _autoRenewTimer = null;

  //Make sure we have the discovery information
  await _verifyDiscoveryDocument();

  //Get the token information and prompt for login if necessary.
  try {
    final response = await OpenIdConnect.authorizeInteractive(
      context: context,
      title: title,
      request: await InteractiveAuthorizationRequest.create(
        configuration: configuration!,
        clientId: clientId,
        redirectUrl: this.redirectUrl!,
        clientSecret: this.clientSecret,
        loginHint: userNameHint,
        additionalParameters: additionalParameters,
        scopes: _getScopes(scopes),
        autoRefresh: autoRefresh,
        prompts: prompts,
        useWebPopup: useWebPopup,
        popupHeight: popupHeight,
        popupWidth: popupWidth,
      ),
    );

    if (response == null) throw StateError(ERROR_USER_CLOSED);

    //Load the idToken here
    await _completeLogin(response);

    if (autoRefresh) _setupAutoRenew();

    _raiseEvent(AuthEvent(AuthEventTypes.Success));

    return _identity!;
  } on Exception catch (e) {
    clearIdentity();
    _raiseEvent(AuthEvent(AuthEventTypes.Error, message: e.toString()));
    throw AuthenticationException(e.toString());
  }
}