CC Experiment-8
CC Experiment-8
CC Experiment-8
Aim: Design an Assignment to retrieve, verify, and store user credentials using Firebase
Authentication
Description:
1. Authentication: Firebase provides a secure and easy way for users to sign into their
app. Developers can use Firebase Authentication to support email and password login,
Google Sign-In, Facebook Login and more.
2. Realtime Database: The Firebase Realtime Database is a cloud-hosted NoSQL
database that lets organizations store and sync data in real time across all their users'
devices. This makes it easy to build apps that are always up to date, even when users
are offline.
3. Cloud Messaging: Firebase Cloud Messaging (FCM) is a service that lets businesses
send messages to their users' devices, even if they're not using the app. Developers
can use FCM to send push notifications, update app content, and more.
4. Crashlytics: Firebase Crashlytics is a service that helps organizations track and fix
crashes in their app. Crashlytics provides detailed reports on crashes, so they can
quickly identify the root cause and fix the problem.
5. Performance Monitoring: Firebase Performance Monitoring provides insights into
the performance of their app. Organizations can use Performance Monitoring to track
metrics like CPU usage, memory usage and network traffic.
6. Test Lab: Firebase Test Lab is a cloud-based service that lets developers test their
app on a variety of devices and configurations. This helps them ensure the app works
well on a variety of devices and in different network conditions.
Aim: Design an Assignment to retrieve, verify, and store user credentials using Firebase
Authentication
Description:
1. Authentication: Firebase provides a secure and easy way for users to sign into their
app. Developers can use Firebase Authentication to support email and password login,
Google Sign-In, Facebook Login and more.
2. Realtime Database: The Firebase Realtime Database is a cloud-hosted NoSQL
database that lets organizations store and sync data in real time across all their users'
devices. This makes it easy to build apps that are always up to date, even when users
are offline.
3. Cloud Messaging: Firebase Cloud Messaging (FCM) is a service that lets businesses
send messages to their users' devices, even if they're not using the app. Developers
can use FCM to send push notifications, update app content, and more.
4. Crashlytics: Firebase Crashlytics is a service that helps organizations track and fix
crashes in their app. Crashlytics provides detailed reports on crashes, so they can
quickly identify the root cause and fix the problem.
5. Performance Monitoring: Firebase Performance Monitoring provides insights into
the performance of their app. Organizations can use Performance Monitoring to track
metrics like CPU usage, memory usage and network traffic.
6. Test Lab: Firebase Test Lab is a cloud-based service that lets developers test their
app on a variety of devices and configurations. This helps them ensure the app works
well on a variety of devices and in different network conditions.
In this Practical, we are going to study to store retrieve and verify the user credentials.
Follow the steps below:
First of all open the firebase portal by click on link https://firebase.google.com/
Click on “Go to Console” and then click on “Add Project”
Enter the Project name of your choice in the field in our case it is “priceless”
Now add the firebase functionality of Authentication to the project by clicking on
“Authentication”
Click on “Sign In Method” then enable the “Email / Password” method-provider. Note
don’t enable the google analytics.
Same way add the functionality of firebase “Realtime Database” and goto “Rules tab and
set value for “read” and “write” as “true”.
<html>
<head>
<title>Firebase Authentication Web Application </title>
</head>
<body>
<h1> Signup</h1>
<table>
<tr>
<td>Username </td>
<td><input type="text" id="username" name="username"
placeholder="username" /> </td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" id="email" name="email" placeholder="E-mail" /> </td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" id="password" name="password"
placeholder="password" /></td>
</tr>
<tr >
<td colspan="3" align="center"><input type="submit" id="signup" name="signup"
Value = "signup" /></td>
</tr>
</table>
</body>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-
analytics.js";
import { getDatabase } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-
database.js";
import { getAuth, createUserWithEmailAndPassword } from
"https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const database = getDatabase(app);
const auth = getAuth();
</html>
In firebase cloud we will have entry of user created with parameters as follows
<html>
<head>
<title>Firebase Authentication Web Application </title>
</head>
<body>
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const database = getDatabase(app);
const auth = getAuth();
// ...
} else {
// User is signed out
}
});
</script>
</html>
By click on “Login” we will have following output
Conclusion:
As we have studied for one provider Method “Email/Password”, Similarly we can
implement for other Social Media authentication such as google, Facebook, Twitter etc.. also.
You can also refer the documentation for the same by click on the following link.
https://firebase.google.com/docs/auth/web/google-signin?hl=en&authuser=0