Skip to content
Back to archipelago.banuacoder.com

Feature SDKs (Pro)

social_auth_sdk Pro ​

Tier
Proversion 2.0.5
Command
archipelago generate social_auth_sdk
Generates
  • features/social_auth/social_auth_api
  • features/social_auth/social_auth_impl
  • features/social_auth/apple_social_auth_impl (if selected)
  • features/social_auth/facebook_social_auth_impl (if selected)
  • features/social_auth/google_social_auth_impl (if selected)
Generates first
monitoring_sdk, auth_sdkwhen needed and missing, so there is nothing to install first

Social authentication feature SDK with per-provider packages (Google, Apple, Facebook), mirroring analytics_sdk's multi-impl pattern. Integrates with auth_sdk for seamless login flow.

Variables ​

VariableTypeDefaultDescription
includeGooglebooleantrueGenerate google_social_auth_impl (Google Sign-In)
includeApplebooleantrueGenerate apple_social_auth_impl (required by App Store whenever any other provider is enabled)
includeFacebookbooleanfalseGenerate facebook_social_auth_impl (Facebook Login)

Install ​

Interactive ​

bash
archipelago generate social_auth_sdk

Non-interactive (CI) ​

bash
archipelago generate social_auth_sdk --config my_config.json

pre_gen aborts generation (exit code 1) if all three provider flags are false — at least one provider must be enabled. If includeApple is false while another provider is true, it prints a warning (not an abort): Apple App Store guideline 4.8 requires Sign in with Apple whenever another third-party social login is offered.

Prerequisites ​

social_auth_impl path-depends directly on the auth_api and monitoring_api packages, and the SocialAuthSDK factory reads AuthSDK and AppMonitoring when the SDK is first resolved. pre_gen self-generates monitoring_sdk first and then auth_sdk via SubBrickGenerator if either is missing, so no manual step is needed.

Generated Packages ​

PackageConditionDescription
social_auth_apiAlwaysContract + shared models (no plugin deps)
social_auth_implAlwaysOrchestrator — discovers provider handlers via getIt.getAll(), integrates with AuthSDK/AppMonitoring
google_social_auth_implincludeGoogleGoogle Sign-In handler (google_sign_in)
apple_social_auth_implincludeAppleSign in with Apple handler (sign_in_with_apple)
facebook_social_auth_implincludeFacebookFacebook Login handler (flutter_facebook_auth)

Generated Structure ​

text
features/
└── social_auth/
    ├── social_auth_api/
    │   └── lib/src/
    │       ├── social_auth_sdk.dart
    │       ├── social_auth_provider_handler.dart
    │       └── models/               # SocialAuthProvider, SocialAuthResult, SocialAuthCredential, SocialAuthFailureReason
    ├── social_auth_impl/
    │   └── lib/src/
    │       ├── social_auth_sdk_impl.dart
    │       └── di/
    ├── google_social_auth_impl/      # if includeGoogle
    ├── apple_social_auth_impl/       # if includeApple
    └── facebook_social_auth_impl/    # if includeFacebook

Mason renders all three provider directories unconditionally (mustache path gating leaves empty dirs); post_gen.dart's _cleanupDisabledProviders deletes the ones whose flag is false.

Public API ​

dart
final socialAuth = getIt<SocialAuthSDK>();

if (socialAuth.isProviderAvailable(SocialAuthProvider.google)) {
  final result = await socialAuth.signIn(SocialAuthProvider.google);
  switch (result) {
    case SocialAuthSuccess():
      // orchestrator already called AuthSDK.loginSuccess(userId: ...) for you
      break;
    case SocialAuthCancelled():
      break; // user tapped back — silent, no monitoring
    case SocialAuthFailure(:final reason):
      break; // reason: notSupported | providerError
  }
}

await socialAuth.signOut(); // fans out to every registered provider, idempotent

availableProviders only reflects providers whose package was actually generated and wired into DI — use it to conditionally show login buttons. Calling signIn() for a provider with no registered handler returns SocialAuthFailure(reason: notSupported) without throwing or logging; any exception a handler throws is caught, reported to AppMonitoring, and returned as SocialAuthFailure(reason: providerError).

DI & Wiring ​

The post-gen hook wires everything into the app's injector.dart and pubspec.yaml automatically — no manual DI edits required:

  1. Each enabled provider's *PackageModule is registered first (as an external module). Each handler registers as @Named('<provider>') (google, facebook, apple), so several providers can coexist.
  2. SocialAuthImplGlobalModule (the orchestrator) is registered last; its lazy factory resolves every registered handler through getIt.getAll<SocialAuthProviderHandler>().
  3. Disabled providers are stripped from both the injector and the app's pubspec.yaml on re-runs with changed flags.

SocialAuthImplGlobalModule registers SocialAuthSDK as a lazy singleton (since 2.0.0). Nothing runs at boot: each handler initialises its vendor SDK on its first sign-in, and the handler list is read when the SDK is first resolved.

Dependencies ​

  • google_social_auth_impl: google_sign_in ^7.2.0
  • apple_social_auth_impl: sign_in_with_apple ^8.1.0, crypto ^3.0.7
  • facebook_social_auth_impl: flutter_facebook_auth ^7.2.0
  • social_auth_api/social_auth_impl: no vendor SDKs — equatable, feature_sdk, monitoring_api, auth_api only

Platform Setup ​

None of this is automated by hooks — each provider needs manual dashboard/native config:

Google Sign-In ​

  1. Add your OAuth 2.0 client ID to android/app/build.gradle (resValue) and iOS Info.plist (CFBundleURLSchemes).
  2. See: https://pub.dev/packages/google_sign_in

Sign in with Apple ​

  1. Enable the Sign in with Apple capability in Xcode.
  2. Configure an Apple Services ID for web/Android redirect.
  3. See: https://pub.dev/packages/sign_in_with_apple

Facebook Login ​

  1. Add your App ID and Client Token to android/app/res/values/strings.xml and iOS Info.plist.
  2. See: https://pub.dev/packages/flutter_facebook_auth

Limitations ​

  • No platform files (manifests, plist, gradle) are written automatically for any provider — all three require manual dashboard setup per-provider.
  • Apple App Store guideline 4.8 compliance is only a generation-time warning, never enforced — you can still generate and ship Google/Facebook without Apple.

Changelog ​

Run archipelago brick info social_auth_sdk to see the latest published version. Enterprise customers can read the full CHANGELOG.md in the brick source repository.