This project is a comprehensive, full-stack demonstration of how to implement Google Sign-In in an Android application with a secure backend verification system. It showcases the modern approach using Android's Credential Manager API and a Node.js (Express) backend to validate Google ID tokens.
The primary goal is to provide a clear, end-to-end example of a secure authentication flow, from the user tapping the "Sign in with Google" button on their device to the backend server verifying their identity and issuing a session token.
The repository is organized into two main parts:
./android
: Contains the native Android application built with Kotlin. It handles the user interface, Google Sign-In flow via Credential Manager, and communication with the backend../backend
: Contains the Node.js (Express) server built with TypeScript. It exposes an API endpoint to verify Google ID tokens and issue custom JWTs for session management.
- Android Client (using Credential Manager):
- Modern, simplified Google Sign-In implementation.
- Login screen with a "Sign in with Google" button.
- Profile screen to display user information after successful login.
- Securely sends the Google ID token to the backend.
- Node.js Backend:
- Verifies the integrity and authenticity of Google ID tokens.
- Issues custom JSON Web Tokens (JWTs) to the client for session management.
- Built with Express.js and TypeScript for a robust and scalable setup.
- Frontend (Android):
- Kotlin
- Firebase Authentication
- Google Sign-In with Credential Manager API
- Backend:
- Node.js with Express.js
- TypeScript
- Bun (runtime and package manager)
- JSON Web Tokens (JWT)
- Google Auth Library
To run this demo, you need to set up a Firebase project, configure the backend, and then run the Android application.
Follow the detailed instructions in the Android README to:
- Create a Firebase project.
- Add your Android app to the project.
- Enable the Google Sign-In provider.
- Add your SHA-1 fingerprint.
- Crucially, obtain your Web Client ID, which is needed for both the Android app and the backend.
- Navigate to the
backend
directory. - Follow the instructions in the backend README to install dependencies and create your
.env
file. - Start the backend server:
The server will be running at
cd backend bun run dev
http://localhost:3000
.
- Follow the instructions in the Android README to add your Web Client ID to the project.
- Set up a reverse proxy to allow the app to communicate with your local backend:
# Make sure your Android device is connected or emulator is running adb reverse tcp:3000 tcp:3000
- Build and run the app on your Android device or emulator.
For more detailed information on each part of the project, please refer to their respective README files: