패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소dhc-tech/apple_sign_in_plugin

apple_sign_in_plugin

dhc-tech/apple_sign_in_plugin open-source repository details.

apple_sign_in_plugin 프로젝트 이미지
스타
5
포크
0
최근 푸시(UTC)
2026. 2. 18.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

Apple Sign In Plugin

pub package License: MIT

A comprehensive Flutter package for integrating Apple Sign-In with features for secure authentication and user data management. It handles the complete flow, including token exchange and refresh, making it ready for backend integration.

✨ Features

  • 🔐 Secure Authentication: Handles the complete Apple Sign-In flow securely.
  • 📦 Backend Ready: Returns idToken, accessToken, and refreshToken essential for server-side verification.
  • 🔄 Token Management: Automatically handles token refreshes and revocations.
  • 👤 User Data: Retrieves name, email, and stable user ID.
  • 📱 Cross-Platform: Supports iOS, macOS, Android, and Web.

📱 Platform Support

Platform Supported Implementation Note
iOS ✅ Native Framework
macOS ✅ Native Framework
Android ✅ via Apple Web Auth
Web ✅ via Apple JS SDK

🛠 Prerequisites

Before using this plugin, ensure you have the following configured in your Apple Developer Account:

  1. App ID & Service ID: Created and configured for Sign in with Apple.
  2. Team ID: Your 10-character Team ID.
  3. Key ID: The ID of your private key.
  4. Private Key file (.p8): Downloaded from Apple. Rename it to apple_private_key.pem.

📦 Installation

Add this to your package's pubspec.yaml file:

dependencies:
  apple_sign_in_plugin: ^1.2.6

⚙️ Setup & Configuration

1. Asset Configuration (Required)

Add your .pem private key file to your Flutter assets in pubspec.yaml:

flutter:
  assets:
    - assets/keys/apple_private_key.pem
2. iOS / macOS
  • Open your project in Xcode.
  • Go to Signing & Capabilities.
  • Add the Sign in with Apple capability.
3. Android / Web
  • Ensure you have created a Service ID in the Apple Developer Console.
  • Configure your Return URLs and Web Domain for the Service ID.

🚀 Usage

1. Initialize

Initialize the plugin once, preferably in main.dart or before the first usage.

await AppleSignInPlugin.initialize(
  pemKeyPath: 'assets/keys/apple_private_key.pem',
  keyId: 'YOUR_KEY_ID',
  teamId: 'YOUR_TEAM_ID',
  bundleId: 'YOUR_BUNDLE_ID', // Must match your Service ID
);
2. Sign In

Call signInWithApple() to start the authentication flow.

try {
  final result = await AppleSignInPlugin.signInWithApple();

  if (result != null) {
      print("Sign In Successful!");
      print("ID Token: ${result.idToken}"); 
      print("Email: ${result.email}");
      print("User ID: ${result.userIdentifier}");
  } else {
      print("Sign In Cancelled");
  }
} catch (e) {
  print("Sign In Failed: $e");
}
3. Sign Out

Securely signs the user out and invalidates the tokens.

await AppleSignInPlugin.signOut();
4. Check State

Check if the user is currently considered logged in (locally).

bool isLoggedIn = AppleSignInPlugin.isSignedIn();

📦 The Result Object (AppleSignInResult)

The plugin returns an AppleSignInResult object containing all necessary data.

Field Description Usage
idToken JSON Web Token (JWT). Verify on Backend. Proves user identity.
accessToken Short-lived Apple API token. Accessing Apple APIs.
refreshToken Long-lived token. Getting new access tokens.
userIdentifier Unique User ID. Database Key. Identify users in your DB.
email User's email. User contact/profile.
givenName First Name. User profile (First login only).
familyName Last Name. User profile (First login only).
authorizationCode One-time code. Used internally for token exchange.

❓ Troubleshooting

Error Code Possible Cause Solution
invalid_client Incorrect credentials. Check Team ID, Key ID, Bundle ID, and ensure the .pem file is correct and loaded.
invalid_grant Expired/Used code. Expected if reusing a code. Sign in again to get a fresh code.
invalid_request Missing parameters. Verify all initialize() parameters are non-empty strings.
Simulation Fail iOS Simulator issue. Test on a Real Device. Simulators often fail with Keychain errors.

📄 License

MIT License. See LICENSE for details.

Digvijaysinh Chauhan GitHub avatar
GitHub 작성자

Digvijaysinh Chauhan ↗

언어DartC++CMakeRubySwiftHTMLCKotlinObjective-C

사용 중인 의존성

의존성 목록 7 개

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗