A Python FastAPI app with SQL backend and social login support for Google, Facebook, and Apple.
- FastAPI backend
- SQLAlchemy PostgreSQL-ready database layer
- Docker and Docker Compose support
- Dev container configuration
- OAuth-ready routes for Google, Facebook, and Apple
- Demo login endpoint for local testing
- Copy
.env.exampleto.env - Set provider credentials in
.envfor social login providers - Run:
docker compose up --build- Visit
http://localhost:8000
GET /- landing pageGET /health- health checkGET /auth/providers- available providersGET /auth/login/{provider}- redirect to the provider loginPOST /auth/demo- demo loginGET /users- list users
The project is configured to deploy with Railway using railway.json and the Dockerfile.
Set the following Railway environment variables in your project settings:
DATABASE_URLSECRET_KEYGOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETFACEBOOK_CLIENT_IDFACEBOOK_CLIENT_SECRETAPPLE_CLIENT_IDAPPLE_TEAM_IDAPPLE_KEY_IDAPPLE_PRIVATE_KEYDEMO_EMAIL
If you do not configure the provider variables, the app will still start, but provider login endpoints will return a provider-not-configured error.
When registering OAuth apps, use these callback URLs for local and Railway deployment:
-
Local development:
http://localhost:8000/auth/callback/googlehttp://localhost:8000/auth/callback/facebookhttp://localhost:8000/auth/callback/apple
-
Railway / production:
https://<your-railway-app>.up.railway.app/auth/callback/googlehttps://<your-railway-app>.up.railway.app/auth/callback/facebookhttps://<your-railway-app>.up.railway.app/auth/callback/apple
- Create an OAuth 2.0 Client ID in Google Cloud Console.
- Set
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET. - Add both the local and Railway callback URLs to Authorized redirect URIs.
- Create a Facebook App in Meta for Developers.
- Set
FACEBOOK_CLIENT_IDandFACEBOOK_CLIENT_SECRET. - Add the callback URLs under Valid OAuth Redirect URIs.
- Ensure the app is in development mode or approved for public use.
- Create an App ID or Service ID in Apple Developer.
- Generate a private key and keep the full key text in
APPLE_PRIVATE_KEY. - Set
APPLE_CLIENT_ID,APPLE_TEAM_ID,APPLE_KEY_ID, andAPPLE_PRIVATE_KEY. - Add the callback URLs in your Apple Sign In settings.
- Use
POST /auth/demoto create a demo user without external provider setup. - Use
.envlocally anddocker compose up --buildto start the app.