enableAuthProviders method

Future<AuthProvidersResult> enableAuthProviders({
  1. required Set<AuthProvider> providers,
  2. bool interactive = true,
})

Walk the user through enabling each requested Firebase Auth provider.

Auth provider toggles are intentionally a console hand-off rather than an automation:

• Email/Password could be flipped via the Identity Toolkit Admin REST API, but that requires an OAuth bearer token with the https://www.googleapis.com/auth/firebase scope. Asking the user to mint that token is more friction than just clicking a single toggle in the browser. • Google sign-in cannot be fully automated at all — the OAuth client still has to be configured by hand in Google Cloud Console, including the consent screen and authorized domains.

This method therefore prints the list of providers, opens (well — emits) the relevant URLs, and confirms with the user. It always succeeds when interactive is false (silent skip).

Behaviour for both Flutter and Jaspr templates is identical: the console URL is the same regardless of client framework.

Implementation

Future<AuthProvidersResult> enableAuthProviders({
  required Set<AuthProvider> providers,
  bool interactive = true,
}) async {
  if (projectId.isEmpty) {
    return AuthProvidersResult(
      requested: providers,
      automated: const <AuthProvider>{},
      handedOff: const <AuthProvider>{},
      message: 'No Firebase project ID configured',
    );
  }

  if (providers.isEmpty) {
    return const AuthProvidersResult(
      requested: <AuthProvider>{},
      automated: <AuthProvider>{},
      handedOff: <AuthProvider>{},
    );
  }

  if (!interactive) {
    info(
      'Non-interactive mode: skipping auth provider hand-off for ${providers.map((AuthProvider p) => p.label).join(', ')}',
    );
    return AuthProvidersResult(
      requested: providers,
      automated: const <AuthProvider>{},
      handedOff: const <AuthProvider>{},
      message: 'Run `oracular deploy auth-providers` interactively',
    );
  }

  UserPrompt.printDivider(title: 'Enable Firebase Auth providers');
  UserPrompt.printList(<String>[
    'Open: ${authProvidersConsoleUrl(projectId)}',
    for (final AuthProvider p in providers) _instructionFor(p),
    if (providers.contains(AuthProvider.google))
      'Google OAuth client config: ${oauthConsentUrl(projectId)}',
    'Authorized domains (add web hosting domains): ${authDomainsConsoleUrl(projectId)}',
  ]);
  print('');

  final bool confirmed = await UserPrompt.askYesNo(
    'Have you enabled the providers above?',
    defaultValue: true,
  );

  if (!confirmed) {
    warn(
      'Auth providers not yet enabled. Re-run `oracular deploy auth-providers` once they are configured.',
    );
    return AuthProvidersResult(
      requested: providers,
      automated: const <AuthProvider>{},
      handedOff: const <AuthProvider>{},
      message: 'User skipped Auth provider enablement',
    );
  }

  return AuthProvidersResult(
    requested: providers,
    automated: const <AuthProvider>{},
    handedOff: providers,
  );
}