Feature SDKs
How to add Google, Apple and Facebook sign-in to a Flutter app
Pro Reference for social_auth_sdk: every variable, option and package it generates. Command: archipelago generate social_auth_sdk
Generate the Social Auth SDK with per-provider flags, configure each provider, and meet the App Store rule for Sign in with Apple.
What you'll learn
- Generating the Social Auth SDK with per-provider feature flags
- Understanding the generated package structure and DI wiring order
- Configuring Google Sign-In, Sign in with Apple, and Facebook Login
- Apple's App Store requirement for Sign in with Apple
Prerequisites
- An existing Archipelago monorepo (see Monorepo Scaffolding)
- A Pro subscription or higher
The brick generates monitoring_sdk and auth_sdk for you if they are missing. The orchestrator calls AuthSDK.loginSuccess and reports to AppMonitoring.
Step 1: Generate the Social Auth SDK
archipelago generate social_auth_sdkThe prompts are:
- includeGoogle: Google Sign-In (default
true) - includeApple: Sign in with Apple (default
true) - includeFacebook: Facebook Login (default
false)
Generation stops if all three are false.
App Store policy
Apple requires Sign in with Apple whenever your app offers any other third-party login. If you set includeApple: false while enabling Google or Facebook, the generator prints a warning. It does not stop. App Store review can reject your app unless you add Sign in with Apple before you submit.
Or use a config file:
{
"includeGoogle": true,
"includeApple": true,
"includeFacebook": false
}archipelago generate social_auth_sdk --config social_auth_config.jsonStep 2: Understand the Generated Structure
The brick generates one package per enabled provider plus a shared API contract and an orchestrator impl:
features/social_auth/
├── social_auth_api/
│ └── lib/src/
│ └── social_auth_sdk.dart # Shared contract
├── social_auth_impl/
│ └── lib/src/
│ └── social_auth_impl.dart # Orchestrator (wires providers)
├── google_social_auth_impl/ # includeGoogle=true
│ └── lib/src/
│ └── google_social_auth_impl.dart
├── apple_social_auth_impl/ # includeApple=true
│ └── lib/src/
│ └── apple_social_auth_impl.dart
└── facebook_social_auth_impl/ # includeFacebook=true (if enabled)
└── lib/src/
└── facebook_social_auth_impl.dartStep 3: Check the Registration
The post-generation hook wires the DI for you. You write no registration code.
- Each enabled provider module registers first. Each handler is
@Namedwithgoogle,appleorfacebook, so providers coexist. SocialAuthImplGlobalModuleregisters last. It registersSocialAuthSDKas a lazy singleton. The handler list is read the first time something resolves the SDK.- Nothing runs at boot. Each handler starts its vendor SDK on its first sign-in.
- A provider you turn off on a later run is removed from the injector and the app
pubspec.yaml.
Step 4: Configure Google Sign-In
The hooks write no platform files. Follow the google_sign_in setup guide.
Android: add the OAuth 2.0 client ID as a resValue in android/app/build.gradle:
android {
defaultConfig {
resValue "string", "default_web_client_id", "<YOUR_CLIENT_ID>.apps.googleusercontent.com"
}
}iOS: add the reversed client ID to Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.YOUR_CLIENT_ID</string>
</array>
</dict>
</array>Step 5: Configure Sign in with Apple
Follow the sign_in_with_apple setup guide.
- In Xcode, enable the Sign in with Apple capability under your app's target → Signing & Capabilities.
- In the Apple Developer portal, configure a Services ID for web/Android redirect support (required for non-iOS platforms).
- No
Info.plistorbuild.gradlechanges needed, the capability alone is sufficient for iOS.
Step 6: Configure Facebook Login (optional)
Follow the flutter_facebook_auth setup guide.
Android: add to android/app/src/main/res/values/strings.xml:
<string name="facebook_app_id">YOUR_APP_ID</string>
<string name="facebook_client_token">YOUR_CLIENT_TOKEN</string>iOS: add to Info.plist:
<key>FacebookAppID</key>
<string>YOUR_APP_ID</string>
<key>FacebookClientToken</key>
<string>YOUR_CLIENT_TOKEN</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbYOUR_APP_ID</string>
</array>
</dict>
</array>Step 7: Use the Social Auth API
Take SocialAuthSDK by constructor. Show a button only for providers that exist:
if (socialAuth.isProviderAvailable(SocialAuthProvider.google)) {
final result = await socialAuth.signIn(SocialAuthProvider.google);
switch (result) {
case SocialAuthSuccess():
// The orchestrator already called AuthSDK.loginSuccess for you.
break;
case SocialAuthCancelled():
break; // The user backed out. This is silent.
case SocialAuthFailure(:final reason):
break; // reason: notSupported or providerError
}
}
await socialAuth.signOut(); // every provider, safe to repeatavailableProviders lists the providers wired into DI. A call for a provider with no handler returns SocialAuthFailure(notSupported) and does not throw. An exception in a handler goes to AppMonitoring and returns SocialAuthFailure(providerError).
Common Customizations
| Customization | Where to Change |
|---|---|
| Add a provider later | Run archipelago generate social_auth_sdk again with the new flag set to true |
| Custom error handling | The handler in the provider package. Errors go to AppMonitoring |
| Scope changes (Google) | Pass scopes to GoogleSignIn() in google_social_auth_impl |
| Server-side token exchange | Change social_auth_sdk_impl.dart and your auth_sdk backend calls |
Next Steps
- Set up Monitoring to track social login success and failure rates
- Configure the UI Kit to add social login buttons to the generated login page