Prompt Library 💻 Coding & Dev Implement OAuth 2.0 and Social Login
Any 💻 Coding & Dev Advanced

Implement OAuth 2.0 and Social Login

Add Google, GitHub, or other OAuth providers to any application.
👁 5 views ⎘ 0 copies ♥ 0 likes

The Prompt

Implement OAuth 2.0 social login for the following:

Application type: [web app / mobile app / API]
Backend: [Node.js/Express / Python/FastAPI / Django / Laravel / other]
Frontend: [React / Vue / Next.js / vanilla / other]
Providers to implement: [Google / GitHub / Facebook / Apple / Microsoft / other]
Database: [PostgreSQL / MySQL / MongoDB / other]
Existing auth: [adding to existing email+password / OAuth only / no existing auth]
Session management: [JWT / server sessions / cookies]
Special requirements: [link multiple providers to one account / other]

Provide a complete OAuth implementation:

OAUTH FLOW EXPLANATION:
- OAuth 2.0 authorization code flow diagram (described)
- PKCE implementation (if applicable)
- State parameter and CSRF protection

PROVIDER SETUP:
For each provider:
- Developer console setup instructions
- Required credentials and where to store them
- Callback URL configuration
- Scope recommendations
- Provider-specific quirks

BACKEND IMPLEMENTATION:
- OAuth route setup (initiate and callback)
- Token exchange code
- User info fetching from provider
- Account matching logic:
  - New user: create account
  - Existing user same email: link account
  - Existing user different email: create new
- Session creation after OAuth success
- Error handling for OAuth failures

FRONTEND IMPLEMENTATION:
- Login button components
- OAuth redirect initiation
- Callback page handling
- Token storage after success
- Error state handling

DATABASE SCHEMA:
- User table additions for OAuth
- OAuth accounts table (for multiple providers per user)
- Token storage if needed

SECURITY CHECKLIST:
- State parameter validation
- Redirect URI validation
- Token storage best practices
- Refresh token handling
- Account takeover prevention

TESTING:
- How to test OAuth flows locally
- Mocking OAuth providers in tests
- E2E test approach

📝 Fill in the blanks

Replace these placeholders with your own content:

[web app / mobile app / API]
[Node.js/Express / Python/FastAPI / Django / Laravel / other]
[React / Vue / Next.js / vanilla / other]
[Google / GitHub / Facebook / Apple / Microsoft / other]
[PostgreSQL / MySQL / MongoDB / other]
[adding to existing email+password / OAuth only / no existing auth]
[JWT / server sessions / cookies]
[link multiple providers to one account / other]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into Any

Open your preferred AI assistant and paste the prompt to get started.