# Setup Apple Signin

> Set up Sign In with Apple in a Flutter + Firebase app — Developer Portal App ID/Services ID/key, Firebase config, Dart code for iOS-native and Android/web. Use when adding Apple login or fixing operation-not-allowed/invalid_client.

- Skill: `rockclaver/setup-apple-signin` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add rockclaver/setup-apple-signin`
- Raw SKILL.md: https://api.skillmd.com/api/skills/rockclaver/setup-apple-signin/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: rockclaver (https://skillmd.com/u/rockclaver)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/rockclaver/setup-apple-signin

---


# Setup Apple Sign-In (Flutter + Firebase)

Wire up Sign In with Apple across iOS, Android, and web through Firebase Auth. Three systems must agree: Apple Developer Portal, Firebase Console, and app code.

## Quick start (iOS-only apps)

`pubspec.yaml`: `firebase_auth` is sufficient — no extra package needed.

```dart
Future<UserCredential> signInWithApple() =>
    FirebaseAuth.instance.signInWithProvider(
      AppleAuthProvider()..addScope('email')..addScope('name'),
    );
```

On iOS/macOS this presents Apple's **native** sheet. Enable the **Apple** provider in Firebase Console → Authentication → Sign-in method → Apple → Save. That's the entire setup for iOS-only.

## Setup checklist (add Android/web/desktop)

Apple has no native SDK outside iOS/macOS — `signInWithProvider` falls back to a **web redirect** through `https://<project>.firebaseapp.com/__/auth/handler`, which needs real OAuth registration:

1. **Xcode**: add "Sign In with Apple" capability → writes `com.apple.developer.applesignin` to `Runner.entitlements`. Auto-registers the App ID capability in the Developer Portal on next archive with automatic signing.
2. **Apple Developer Portal → Keys**: create a key with Sign In with Apple enabled, Primary App ID = your bundle ID. Download the `.p8` **once**; note the Key ID.
3. **Apple Developer Portal → Identifiers → Services IDs**: create one (e.g. `com.you.app.web`, must differ from the bundle ID). Enable Sign In with Apple → Configure → Primary App ID, Domain = `<project>.firebaseapp.com`, Return URL = `https://<project>.firebaseapp.com/__/auth/handler`. Save all three dialogs.
4. **Firebase Console → Apple provider → OAuth code flow configuration**: Services ID, Team ID, Key ID, full `.p8` contents. Save (server-side, no rebuild).
5. **Android**: register the app's SHA-1/SHA-256 in Firebase Project Settings so the redirect handler returns correctly.

Full step-by-step with exact field values: [REFERENCE.md](REFERENCE.md).

## Code

Native sign-in, linking, unlinking, and the `sign_in_with_apple` package alternative (for a HIG-compliant native button): [EXAMPLES.md](EXAMPLES.md).

## Something's broken

`operation-not-allowed` vs `invalid_client`, the platform routing trap, and a one-request bisection test that pinpoints Services ID vs key misconfiguration in seconds: [TROUBLESHOOTING.md](TROUBLESHOOTING.md).

