Skip to content

Implement OAuth2 Social Login #19

Description

@Mkalbani

Description

Allow users to sign in with Google, GitHub, Twitter.

Why This Matters

  • Easier onboarding (no password to remember)
  • Higher conversion rates
  • Trusted identity verification

Providers to Support

  • Google OAuth2
  • GitHub OAuth2
  • Twitter OAuth2 (optional)

Acceptance Criteria

  • Add @nestjs/passport with OAuth strategies
  • GET /api/v1/auth/google (redirect to Google)
  • GET /api/v1/auth/google/callback (handle response)
  • Link OAuth account to existing user (if email matches)
  • Create new user if first-time OAuth login
  • Store OAuth tokens securely
  • Allow unlinking OAuth accounts

Database Schema

@Entity('oauth_accounts')
export class OAuthAccount {
  id: number;
  provider: 'google' | 'github' | 'twitter';
  providerId: string; // User ID from provider
  accessToken: string; // Encrypted
  refreshToken: string; // Encrypted
  user: User;
  createdAt: Date;
}

Environment Variables

GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...
GOOGLE_CALLBACK_URL=http://localhost:3000/api/v1/auth/google/callback

GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
GITHUB_CALLBACK_URL=...

Resources

Challenges

  • Token storage security (encrypt!)
  • Account linking (what if email already exists?)
  • Token refresh logic

ETA: 6 hours

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third Campaign

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions