-
Notifications
You must be signed in to change notification settings - Fork 78
docs: Add Firebase IDP docs #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
marcelomendoncasoares
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work with the docs, @exaby73! Have a few suggestions for improvement mainly on the guide.
docs/06-concepts/11-authentication/04-providers/05-firebase/01-setup.md
Outdated
Show resolved
Hide resolved
docs/06-concepts/11-authentication/04-providers/05-firebase/01-setup.md
Outdated
Show resolved
Hide resolved
docs/06-concepts/11-authentication/04-providers/05-firebase/01-setup.md
Outdated
Show resolved
Hide resolved
docs/06-concepts/11-authentication/04-providers/05-firebase/01-setup.md
Outdated
Show resolved
Hide resolved
docs/06-concepts/11-authentication/04-providers/05-firebase/01-setup.md
Outdated
Show resolved
Hide resolved
docs/06-concepts/11-authentication/04-providers/05-firebase/01-setup.md
Outdated
Show resolved
Hide resolved
docs/06-concepts/11-authentication/04-providers/05-firebase/03-customizing-the-ui.md
Show resolved
Hide resolved
marcelomendoncasoares
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last two comments and we are good to go!
| 1. Go to the [Firebase Console](https://console.firebase.google.com/) (create a new project if you don't have one) | ||
| 2. Select your project | ||
| 3. Navigate to **Project settings** > **Service accounts** | ||
| 4. Click **Generate new private key**, then **Generate key** | ||
|
|
||
|  | ||
|
|
||
| This downloads a JSON file containing your service account credentials. | ||
|
|
||
| ### Enable Authentication Methods | ||
|
|
||
| In the Firebase Console, enable the authentication methods you want to support: | ||
|
|
||
| 1. Go to **Authentication** > **Sign-in method** | ||
| 2. Enable your desired providers (Email/Password, Phone, Google, Apple, etc.) | ||
| 3. Configure each provider according to Firebase's documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: For consistency, these two lists are missing the ending punctuation.
| ## Integration patterns | ||
|
|
||
| ### Using firebase_auth directly | ||
|
|
||
| For full control over the authentication UI, use the `firebase_auth` package directly. The basic flow is: | ||
|
|
||
| 1. Build your own sign-in UI with text fields and buttons. | ||
| 2. Call Firebase authentication methods (e.g., `signInWithEmailAndPassword`). | ||
| 3. On success, pass the `firebase_auth.User` to `controller.login()`. | ||
| 4. Handle errors from both Firebase and the Serverpod sync. | ||
|
|
||
| Refer to the [firebase_auth documentation](https://pub.dev/packages/firebase_auth) for available authentication methods. | ||
|
|
||
| ### Using firebase_ui_auth | ||
|
|
||
| For a pre-built UI experience, use the `firebase_ui_auth` package. This provides ready-made screens for various authentication methods. | ||
|
|
||
| 1. Add the package: `flutter pub add firebase_ui_auth`. | ||
| 2. Use `firebase_ui.SignInScreen` with your desired providers. | ||
| 3. Add `AuthStateChangeAction` handlers for `SignedIn` and `UserCreated` events. | ||
| 4. In each handler, call `controller.login()` with the Firebase user. | ||
|
|
||
| ```dart | ||
| actions: [ | ||
| firebase_ui.AuthStateChangeAction<firebase_ui.SignedIn>((context, state) async { | ||
| final user = firebase_auth.FirebaseAuth.instance.currentUser; | ||
| if (user != null) { | ||
| await controller.login(user); | ||
| } | ||
| }), | ||
| ], | ||
| ``` | ||
|
|
||
| Refer to the [firebase_ui_auth documentation](https://pub.dev/packages/firebase_ui_auth) for configuration details and available providers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: This section referencing the usage of firebase_ui_auth adds to the first (and may feel redundant by users that read the first one before). It is worth merging the two together instead of separating the explanation.
No description provided.