플랫폼에 관계없이 Dart/Flutter용 Firebase 인증 REST API 래퍼로, Android, iOS, Web, macOS, Windows, Linux에서 원활한 인증을 가능하게 합니다. Firebase의 REST 엔드포인트를 깔끔하고 사용하기 쉬운 인터페이스로 추상화하여 네이티브 SDK가 필요 없도록 설계되었습니다. 최소한의 설정으로 크로스플랫폼 인증을 원하고 인증 흐름을 완전히 제어하고 싶은 개발자에게 적합합니다. 이 패키지는 가볍고 네이티브 Firebase SDK를 사용할 수 없는 환경에서도 신뢰성 있게 작동하도록 설계되었습니다.
사용 사례
크로스 플랫폼 인증
서버 측 인증 통합
웹 및 데스크톱 앱 인증
사용자 정의 인증 흐름
오프라인 우선 애플리케이션
주요 기능
REST 기반의 Firebase 통합
다중 플랫폼 지원
네이티브 SDK 의존성 없음
간단한 API 표면
보안 토큰 처리
적합한 대상
다중 플랫폼을 대상으로 하는 개발자
네이티브 Firebase SDK를 피하는 프로젝트
인증에 세밀한 제어가 필요한 앱
백엔드 통합 플러터 앱
경량 인증 솔루션
고려 사항
수동으로 리프레시 토큰을 관리해야 합니다
REST API 기능에 제한됨
내장된 UI 컴포넌트 없음
네트워크 사용 가능 여부에 따라 다릅니다
REST 호출에 적절한 오류 처리가 필요합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
firebase_auth_rest
A platform independent Dart/Flutter Wrapper for the Firebase Authentication API based on REST
Features
Pure Dart-based implementation
works on all platforms supported by dart
Uses the official REST-API endpoints
Provides high-level classes to manage authentication and users
Supports multiple parallel Logins of different users
Supports automatic background refresh
Supports all login methods
Proivides low-level REST classes for direct API access (import firebase_auth_rest/rest.dart)
Installation
Simply add firebase_auth_rest to your pubspec.yaml and run pub get (or flutter pub get).
Usage
The libary consists of two primary classes - the FirebaseAuth and the FirebaseAccount. You can use the FirebaseAuth class to perform "global" API actions that are not directly tied to a logged in user - This are things like creating accounts and signing in a user, but also functions like resetting a password that a user has forgotten.
The sign in/up methods of FirebaseAuth will provide you with a FirebaseAccount. It holds the users authentication data, like an ID-Token, and can be used to perform various account related operations, like changing the users email address or getting the full user profile. It also automatically refreshes the users credentials shortly before timeout - allthough that can be disabled and done manually.
Thw following code is a simple example, which can be found in full length, including errorhandling, at https://pub.dev/packages/firebase_auth_rest/example. It loggs into firebase as anonymous user, prints credentials and account details and then proceeds to permanently delete the account.
// Create auth instance and sign up as anonymous user
final fbAuth = FirebaseAuth(Client(), "API-KEY");
final account = await fbAuth.signUpAnonymous();
// print credentials und user details
print("Local-ID: ${account.localId}");
final userInfo = await account.getDetails();
print("User-Info: $userInfo");
// delete and dispose the account
await account.delete();
account.dispose();
Documentation
The documentation is available at https://pub.dev/documentation/firebase_auth_rest/latest/. A full example can be found at https://pub.dev/packages/firebase_auth_rest/example.
Testing
If you intend to run the integration tests, you will have to create a firebase project with the authentication enabled. You must enable E-Mail and anonymous authentication and disable the E-Mail enumeration protection. Note: This is only required to run the integration tests. For a normal firebase project you should never disable E-Mail enumeration protection. Finally, you have to create a .env file with the FIREBASE_API_KEY from the project.
Alternatively you can use the firebase emulator for testing. In that case, you will have to set the FIREBASE_EMULATOR_HOST and FIREBASE_EMULATOR_PORT in the .env file as well.