This project demonstrates a contemporary authentication system developed with React Native (Expo) and Firebase Authentication, offering two secure login methods:
- Email & Password Authentication (via Firebase Auth)
- GitHub OAuth Authentication (via a Node.js backend server)
By integrating Firebase and OAuth 2.0, the system provides a secure and adaptable login solution that works seamlessly across both web and mobile platforms.
- Users provide their first name, last name, email, and password.
- The app uses Firebase’s
createUserWithEmailAndPassword()to register a new user account. - Additional details (
firstName,lastName,email,createdAt) are stored in Firestore within theusers/collection. - After registration, the user is redirected to the
/homescreen.
Files involved:
signup.jsx→ Manages user registrationlogin.jsx→ Handles email/password login
GitHub login involves a two-step process between the frontend and backend.
- The app opens the GitHub Authorization page using
expo-auth-session. - Upon successful login, GitHub returns an
authorization code. - This code is sent to the backend server (
server.js) to be exchanged for anaccess_token.
- The
server.jsfile acts as a secure intermediary between GitHub and Firebase. - It receives the
authorization_code, communicates with GitHub’s API to obtain anaccess_token, and returns this token to the mobile app. - The mobile app then authenticates the user using the Firebase method:
const credential = GithubAuthProvider.credential(access_token); await signInWithCredential(auth, credential);
When testing on a real phone using Expo Go, you must make sure the app can reach your backend server.
-
Connect both your laptop and your phone to the same Wi-Fi or Hotspot.
-
Run the following command to find your local IP address:
- Windows:
ipconfig - Mac/Linux:
ifconfig
Example output:
- Windows:
IPv4 Address: 172.20.10.3
Update the backend URL in your login.jsx file:
const res = await fetch("http://172.20.10.3:3000/exchange_github_token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code }),
});Start your backend server:
node server.js
Open the Expo Go app on your phone and try “Login with GitHub”.
✅ If both devices are connected properly, the login will complete successfully and the user will be redirected to /home.