The Basic Firebase Authentication App is a Flutter-based authentication system using Firebase Authentication. This app allows users to sign up, sign in, reset passwords, and use third-party authentication providers like Google and GitHub. Additionally, it supports anonymous login.
- π‘οΈ Firebase Authentication Error Handling: Proper handling of authentication errors with messages for a seamless experience.
- π¨ Attractive UI Design: The app features a modern and user-friendly interface for a seamless experience.
- π Sign Up: Users can create an account by entering their email, password, and confirming their password.
- π Sign In: Users can log in using their registered email and password.
- β Email & Password Validation: Ensures users enter valid email addresses and secure passwords.
- π Forgot Password: Users can reset their password by entering their email. A password reset link is sent to their email inbox.
- π» Anonymous Sign-In: Users can log in without an email and password.
- π Google Sign-In: Users can authenticate using their Google account.
- π GitHub Sign-In: Users can authenticate using their GitHub account.
- π Persistent Login (Wrapper Implementation): Users stay logged in even after restarting the app, eliminating the need for repeated logins.
- Flutter: For building the UI.
- Firebase Authentication: A backend service for authenticating users.
- Dart: For application logic.
- Google Sign-In: Allows users to sign in using their Google accounts.
- GitHub Sign-In: Enables users to log in using their GitHub credentials.
The following dependencies are used in this project:
firebase_core: ^3.12.1
firebase_auth: ^5.5.1
google_sign_in: ^6.3.0
flutter_svg: ^2.0.17
Here are the Firebase authentication error codes and their descriptions handled in the app:
// Sign In With Email And Password
case 'wrong-password':
return 'The password is invalid or the account does not have a password set.';
case 'invalid-email':
return 'The email address is not valid.';
case 'user-disabled':
return 'The user corresponding to the given email has been disabled.';
case 'user-not-found':
return 'No user corresponding to the given email was found.';
// Create User With Email And Password
case 'email-already-in-use':
return 'An account already exists with the given email address.';
case 'operation-not-allowed':
return 'Email/password accounts are not enabled. Enable them in the Firebase Console.';
case 'weak-password':
return 'The password provided is not strong enough.';
// Sign In With Credential
case 'account-exists-with-different-credential':
return 'An account already exists with the email address provided. Sign in using one of the returned providers.';
case 'invalid-credential':
return 'The credential is malformed or has expired.';
case 'invalid-verification-code':
return 'The verification code is not valid.';
case 'invalid-verification-id':
return 'The verification ID is not valid.';
// Reauthenticate With Credential
case 'user-mismatch':
return 'The credential given does not correspond to the user.';
// Sign In With Email Link
case 'expired-action-code':
return 'The OTP in the email link has expired.';
default:
return 'An unknown error occurred.';
- Clone the repository:
https://github.com/PAIshanMadusha/basic-firebase-authentication.git
- Navigate to the project directory:
cd basic-firebase-authentication
- Install dependencies:
flutter pub get
-
πIβve written a detailed Medium article explaining the step-by-step process to connect Firebase to Flutter with screenshots.
-
πRead my blog on Medium here: Link
-
πAlso, you can view my previous project, Taskly Firebase App I have written clearly on the README how to set up Firebase.
- Create a Firebase project at Firebase Console.
- Add Firebase to Your Flutter App: In Firebase Console, select either Android or iOS, depending on your target platform and, Fill the Required details.
- Ensure this If you want to use Google Sign-In, you must generate the SHA-1 key.
- Download the
google-services.json
file (for Android) andGoogleService-Info.plist
(for iOS) and place them in the appropriate folders.
- Navigate to Firebase Authentication by opening the Firebase Console, selecting the "Authentication" tab in the left sidebar Build Section, and then going to the "Sign-in method" tab.
- In the Sign-in method section, enable Email/Password and Anonymous under the Native Providers section.
- Enable Google under the Additional Providers section. If you've generated the SHA-1 key and don't want to fill in other details, simply select your email for the project and save.
- To enable GitHub under the Additional Providers section, follow the below instructions:
-
Access GitHub Developer Settings:
Go to your GitHub profile, select Settings, scroll down to Developer settings, and then click on OAuth Apps. -
Register a New OAuth App:
Click on New OAuth App and fill in the required details. For the Authorization Callback URL, copy the URL from your Firebase console which states:
"To complete setup, add this authorization callback URL to your GitHub app configuration". Paste this URL into the form and click Register App. -
Obtain Credentials:
After registering, you will see the Client ID. Copy this and paste it into the required field in your Firebase console. Next, generate the Client Secret, copy it, and save it securely as required.
flutter run
Β Β Β Β Β Β
Β Β Β Β Β Β
Β Β Β Β Β Β
Β Β Β Β Β Β
Β Β Β Β Β Β
Ishan Madhusha
GitHub: PAIshanMadusha
Feel free to explore my work and get in touch if you'd like to collaborate! π
This project is open-source and available under the MIT License.