# Authentication
Follow the steps to add Email Authentication, Google Authentication and Apple Authentication to your app
# Configure Authentication
Add latest firebase_core (opens new window) package to pubspec.yaml
Add latest firebase_auth (opens new window) package to pubspec.yaml
Go to firebase console of the project
Click
Get StartedbuttonEnable Email/Password, Google and Apple authentications
Configuring Android App
- Go to
Project Overview > Project Settings - In
Your Appssection, choose Android App - Download
google_services.jsonand copy toandroid/appfolder - Add
classpath 'com.google.gms:google-services:4.3.15'toandroid/build.gradlelike this
buildscript { ext.kotlin_version = '1.7.10' repositories { google() mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.15' } } allprojects { repositories { google() mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } tasks.register("clean", Delete) { delete rootProject.buildDir }- Add
apply plugin: 'com.google.gms.google-services'to bottom ofandroid/app/build.gradle
- Go to
Configuring iOS App
- Go to
Project Overview > Project Settings - In
Your Appssection, choose iOS App - Add team id. This is available at apple developer account (opens new window)
- Download
GoogleService-Info.plistand copy toios/Runnerfolder - Open
Info.pliston Xcode - Drag and drop
GoogleService-Info.plistto Runner folder in xcode - Add the
CFBundleURLTypeswithreverse client idfromGoogleService-Info.plistbelow into the Info.plist file
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>com.googleusercontent.apps.xxxxxxxxxxxxxx</string> </array> </dict> </array>- Inside Podfile uncomment or change it to
platform :ios, '12.0' - Inside
iOS/Flutter/AppFrameworkInfo.plistchange MinimumOSVersion to 12.0 - Delete
podfile.lock - In terminal,
cd iosand runpod install --repo-update
- Go to
# Adding Authentication (Email+Google+Apple)
- Add latest google_sign_in (opens new window) package to pubspec.yaml
- Add latest the_apple_sign_in (opens new window) package to pubspec.yaml
- Add latest webview_flutter (opens new window) package to pubspec.yaml
- Add latest auto_size_text (opens new window) package to pubspec.yaml
- Add latest connectivity_plus (opens new window) package to pubspec.yaml
- Click
Pub geton Android Studio - Download utils folder from here (opens new window) and add it inside
lib/folder - Download tasks folder from here (opens new window) and add it inside
lib/folder - Download authentication folder from here (opens new window) and add it inside
lib/services/folder - Add redirect functionality in splash screen (eg:- Redirect to authentication if user doesn't exist in sqlite, redirect to onboarding if level is 0 and redirect to layout if level = 1)
- Delete
podfile.lock - In terminal,
cd iosand runpod install --repo-update - Run app.
- If Error - DT_TOOLCHAIN_DIR occur, add the highlighted code on Podfile and repeat steps 11-13
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
end
end
end
# Authentication Test
- Sign up with Email
- Sign out
- Login with email wrong Password
- Login with wrong email
- Login
- Sign out
- Send forgot Password email
- Change Password
- Login
- Sign out
- Clean login details from firestore and firebase authentication
- Try registering with google login
- Try login with google Login
- Try registering with apple Login
- Try login with apple Login