This project is an application that implements OAuth2 SSO authentication for Google and Kakao using a SvelteKit frontend and FastAPI backend.
src/- SvelteKit frontend codebackend/- FastAPI backend code
- Google OAuth2 login
- Kakao OAuth2 login
- JWT-based authentication
- User information storage using Supabase database
- Install required packages:
pnpm install- Run development server:
pnpm run devThe frontend runs at http://localhost:5173 by default.
- Navigate to the backend directory:
cd backend- Install required packages:
pip install -r requirements.txt- Set environment variables:
Copy the .env.example file to create a .env file and configure the necessary environment variables:
cp .env.example .env- Run the backend server:
python run.pyThe backend runs at http://localhost:3000 by default.
This project uses Supabase as its database. The following table is required:
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
uuid UUID NOT NULL UNIQUE,
display_name TEXT,
email TEXT NOT NULL UNIQUE,
phone TEXT,
provider TEXT NOT NULL,
provider_type TEXT NOT NULL DEFAULT 'social',
user_status BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMP WITHOUT TIME ZONE,
last_sign_in_at TIMESTAMP WITHOUT TIME ZONE
);- Create a project in the Google Cloud Console.
- Generate an OAuth client ID in API & Services > Credentials.
- Add
http://localhost:3000/api/auth/callback/googleas an authorized redirect URI. - Add the client ID and secret key to the backend
.envfile.
- Create an application on Kakao Developers.
- Add
http://localhost:5173as a site domain in Platform > Web. - Configure Kakao Login in Product Settings.
- Add
http://localhost:3000/api/auth/callback/kakaoas a redirect URI. - Add the REST API key and Client Secret to the backend
.envfile.
- Always use secure HTTPS connections in production environments.
- Keep your JWT secret key strong and secure.
- Store user information with appropriate access management.
