Providers

Apple

Native Sign in with Apple, exchanged with your backend for your own session.

authyra_apple uses the native Sign in with Apple sheet on iOS and macOS, and a browser flow on Android and the web. App Store Review Guideline 4.8 requires it whenever an iOS app offers another social login.

flutter pub add authyra_apple
AppleProvider.withExchange(
  exchange: (credential) async {
    final response = await authApi.post<Map<String, dynamic>>(
      '/auth/apple',
      data: {
        'identity_token': credential.identityToken,
        'authorization_code': credential.authorizationCode,
        'nonce': credential.rawNonce,
        'given_name': credential.givenName,
        'family_name': credential.familyName,
      },
    );
    final user = response.data!['user'] as Map<String, dynamic>;
    return AuthSignInResult(
      user: AuthUser(id: user['id'] as String),
      tokens: tokensFrom(response.data!),
    );
  },
  refresh: refreshWithApi,
  signOut: signOutWithApi,
)
await authyra.signIn('apple');

The credential

FieldNotes
identityTokenA JWT signed by Apple. Your backend verifies its signature against Apple's public keys, aud (your bundle id or Services ID) and exp.
authorizationCodeSingle use, valid five minutes. Your backend can redeem it with Apple.
rawNonceApple received its SHA-256. Your backend checks sha256(rawNonce) == claims.nonce to reject replayed tokens. Firebase and Supabase expect this raw value.
userIdentifierStable Apple user id. Present on iOS and macOS; on Android and the web, read sub from the identity token.
email, givenName, familyNameSent only on the first authorization. Store them on your backend then: Apple never sends them again.

The provider generates a fresh nonce for each sign-in and rejects an identity token carrying another one.

Identity only

AppleProvider()

The session has no tokens. providerData holds identityToken, authorizationCode and rawNonce, for Firebase or Supabase.

Refresh

Apple's own tokens are never refreshed from the app: that needs a client secret signed with a key that must stay on a server. supportsRefresh is true only when you pass refresh, which renews your session with your backend.

Setup

  • Enable the "Sign in with Apple" capability in Xcode.
  • Android and the web need webAuthenticationOptions: a Services ID created on developer.apple.com and a redirect URL on a server you control, which Apple posts the result to.
AppleProvider.withExchange(
  exchange: exchangeApple,
  webAuthenticationOptions: WebAuthenticationOptions(
    clientId: 'com.example.app.service',
    redirectUri: Uri.parse('https://api.example.com/auth/apple/callback'),
  ),
)
On Android, closing the browser tab without finishing leaves the sign-in pending: sign_in_with_apple never completes that call. Let users cancel from your own UI.
Copyright © 2026