SaasCore Docs
  • Get Started
  • Configuration
    • Database
    • Stripe
      • Product ID and Price ID
      • API keys
      • Stripe Webhook
    • Emails
      • Cron Jobs
    • Claudinary
    • Chat plugin
    • Upstash Redis
    • OAuth with Google and GitHub
    • Subscription types and plans
    • Affiliate program
    • Google Analytics Api
  • Landing page
    • Header
    • Hero
      • Discount
      • AvatarCircles
    • Other components
  • Authentication Flow
    • For Admins
    • For Clients
      • OAuth
      • Credentials
    • For Affiliates
  • Payments
    • Payment Flow Scenarios
      • Scenario 1: Registered Client
      • Scenario 2: Direct Subscription from Home Page
      • Upgrading/Downgrading/Canceling Subscriptions
    • Pricing Table
  • Component Protection
  • Pending ...
Powered by GitBook
On this page
  • Google OAuth Setup
  • GitHub OAuth Setup
  • Configuring Your App
  1. Configuration

OAuth with Google and GitHub

PreviousUpstash RedisNextSubscription types and plans

Last updated 9 months ago

This guide will walk you through the process of setting up OAuth authentication for your app using Google and GitHub. You'll need to create OAuth applications on both platforms and retrieve the necessary credentials.

Google OAuth Setup

  1. Create a Google Cloud Project

    • Go to the

    • Create a new project or select an existing one

  2. Enable the Google+ API

    • In the sidebar, navigate to "APIs & Services" > "Library"

    • Search for "Google+ API" and enable it

  3. Create OAuth 2.0 Credentials

    • Go to "APIs & Services" > "Credentials"

    • Click "Create Credentials" and select "OAuth client ID"

    • Choose "Web application" as the application type

    • Set the authorized JavaScript origins to your app's URL (e.g., http://localhost:3000 for local development)

    • Set the authorized redirect URI (e.g., http://localhost:3000/api/auth/callback/google)

  4. Retrieve Google Credentials

    • After creating the OAuth client, you'll see the client ID and client secret

    • Save these as GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET respectively

GitHub OAuth Setup

  1. Create a GitHub OAuth App

    • Go to your GitHub account settings

    • Navigate to "Developer settings" > "OAuth Apps"

    • Click "New OAuth App"

  2. Register the OAuth App

    • Enter your app name

    • Set the homepage URL to your app's main URL

    • Set the Authorization callback URL (e.g., http://localhost:3000/api/auth/callback/github)

  3. Retrieve GitHub Credentials

    • After registering, you'll see the client ID

    • Generate a new client secret

    • Save these as GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET respectively

Configuring Your App

  1. Set Environment Variables

    • In your project's .env file, add the following lines:

      GOOGLE_CLIENT_ID=your_google_client_id_here
      GOOGLE_CLIENT_SECRET=your_google_client_secret_here
      GITHUB_CLIENT_ID=your_github_client_id_here
      GITHUB_CLIENT_SECRET=your_github_client_secret_here
    • Replace the placeholders with your actual credentials

Google Cloud Console