authyra_apple
Native Sign in with Apple for Authyra, built on sign_in_with_apple: the system sheet on iOS and macOS, a browser flow on Android and the web.
App Store Review Guideline 4.8 requires Sign in with Apple whenever an iOS app offers another social login.
Install
flutter pub add authyra_flutter authyra_apple
Enable the "Sign in with Apple" capability in Xcode. Android and the web also need webAuthenticationOptions: a Services ID and a redirect URL on a server you control (see sign_in_with_apple).
With your backend (recommended)
import 'package:authyra_apple/authyra_apple.dart';
AppleProvider.withExchange(
exchange: (credential) async {
// Your backend verifies the identity token and its nonce.
final json = await api.signInWithApple(
identityToken: credential.identityToken,
authorizationCode: credential.authorizationCode,
nonce: credential.rawNonce,
);
return AuthSignInResult(
user: AuthUser(id: json['user_id'] as String),
tokens: AuthTokens.expiringIn(
Duration(seconds: json['expires_in'] as int),
accessToken: json['access_token'] as String,
refreshToken: json['refresh_token'] as String?,
),
);
},
refresh: (refreshToken) => api.refresh(refreshToken), // Your backend.
)
await authyra.signIn('apple');
The provider generates a fresh nonce for each sign-in and rejects an identity token carrying another one. Apple sends email, givenName and familyName only on the first authorization: store them on your backend then.
Identity only
AppleProvider()
The session carries no tokens; providerData holds identityToken, authorizationCode and rawNonce, ready 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.
Known limitation
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.
License
MIT
Libraries
- authyra_apple
- Native Sign in with Apple for Authyra.