Skip to main content

authyra_apple 0.3.0 copy "authyra_apple: ^0.3.0" to clipboard
authyra_apple: ^0.3.0 copied to clipboard

Native Sign in with Apple for Authyra: the system sheet on iOS and macOS, with an optional exchange of Apple's credential for your backend session.

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.

Documentation

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).

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

0
likes
140
points
179
downloads

Documentation

Documentation
API reference

Publisher

verified publishermeragix.dev

Weekly Downloads

Native Sign in with Apple for Authyra: the system sheet on iOS and macOS, with an optional exchange of Apple's credential for your backend session.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#authentication #apple #sign-in-with-apple #session

License

MIT (license)

Dependencies

authyra, crypto, flutter, logging, sign_in_with_apple

More

Packages that depend on authyra_apple