appleProvider function

OAuthProvider<AppleProfile> appleProvider(
  1. AppleProviderOptions options
)

Apple Sign In OAuth provider.

Based on Apple's Sign in with Apple documentation.

Resources

Example

final provider = appleProvider(
  AppleProviderOptions(
    clientId: 'your.service.id',
    clientSecret: 'generated-jwt',
    redirectUri: 'https://example.com/auth/callback/apple',
  ),
);

Implementation

OAuthProvider<AppleProfile> appleProvider(AppleProviderOptions options) {
  return OAuthProvider<AppleProfile>(
    id: 'apple',
    name: 'Apple',
    type: AuthProviderType.oidc,
    clientId: options.clientId,
    clientSecret: options.clientSecret,
    authorizationEndpoint: Uri.parse(
      'https://appleid.apple.com/auth/authorize',
    ),
    tokenEndpoint: Uri.parse('https://appleid.apple.com/auth/token'),
    oidcIssuer: Uri.parse('https://appleid.apple.com'),
    oidcJwksUri: Uri.parse('https://appleid.apple.com/auth/keys'),
    redirectUri: options.redirectUri,
    scopes: options.scopes,
    authorizationParams: {'response_mode': 'form_post'},
    useBasicAuth: false,
    profileParser: AppleProfile.fromJson,
    profileSerializer: (profile) => profile.toJson(),
    profile: (profile) {
      return AuthUser(
        id: profile.sub,
        name: profile.fullName,
        email: profile.email,
        attributes: profile.toJson(),
      );
    },
  );
}