Skip to main content
This guide walks you through your first OAuth provider setup using OAuth Init.

Prerequisites

Before you begin, ensure you have:
  • Node.js 16+ or Bun installed
  • OAuth Init installed globally (see Installation)
  • For Google OAuth: gcloud CLI installed and authenticated

Your first OAuth setup

Let’s set up Google OAuth for a Next.js application.
1

Run OAuth Init

Start the interactive CLI in your project directory:
oauth-init
You’ll see the OAuth Init banner and be prompted for your project name:
  ▗▄▖  ▗▄▖ ▗▖ ▗▖▗▄▄▄▖▗▖ ▗▖    ▗▄▄▄▖▗▖  ▗▖▗▄▄▄▖▗▄▄▄▖
 ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌  █  ▐▌ ▐▌      █  ▐▛▚▖▐▌  █    █
 ▐▌ ▐▌▐▛▀▜▌▐▌ ▐▌  █  ▐▛▀▜▌      █  ▐▌ ▝▜▌  █    █
 ▝▚▄▞▘▐▌ ▐▌▝▚▄▞▘  █  ▐▌ ▐▌    ▗▄█▄▖▐▌  ▐▌▗▄█▄▖  █

┌  Enter the name of your project:
│  my-app

2

Select OAuth providers

Choose which OAuth providers you want to set up. For this guide, select Google:
◆  Select OAuth services to setup:
│  ◻ Google
│  ◻ Github
│  ◻ Discord

Use arrow keys to navigate and Space to select. Press Enter when done.
3

Configure callback URL

OAuth Init automatically detects your auth library and suggests a callback URL:
◇  Detected auth library: next-auth

┌  Enter the Google OAuth callback URL:
│  http://localhost:3000/api/auth/callback/google

Press Enter to accept the default or type your custom callback URL.
4

Select Google Cloud project

OAuth Init fetches your Google Cloud projects using gcloud CLI:
◇  Fetched Projects

◆  Select your project
│  ○ my-production-app
│  ● my-dev-project (Default)
│  ○ another-project

Your current gcloud project is marked as (Default).
5

Configure OAuth consent screen

OAuth Init opens the Google Cloud Console consent screen page:
┌  Action Required

│  1. Choose 'External'
│  2. Fill App Name & Email
│  3. Click 'Save and Continue' through to the end.

└  https://console.cloud.google.com/apis/credentials/consent?project=my-dev-project

┌  Press Enter once you've saved the Consent Screen
│  (or type 'skip' if done previously)

Follow the instructions in the browser, then return to the terminal and press Enter.
6

Create OAuth client ID

OAuth Init opens the credentials creation page:
┌  Action Required

│  1. Select 'Web Application'
│  2. Add your Redirect URIs
│  3. Click 'Create'

└  https://console.cloud.google.com/apis/credentials/oauthclient?project=my-dev-project

┌  Paste your Client ID:
│  123456789-abcdefgh.apps.googleusercontent.com


┌  Paste your Client Secret:
│  ********************************

Copy the Client ID and Client Secret from the Google Cloud Console.
7

Save credentials

Choose how to save your credentials:
◆  Where should we save your credentials?
│  ● .env
│  ○ .env.local
│  ○ JSON file
│  ○ Print to console


◇  Credentials saved to .env
Your .env file now contains:
.env
GOOGLE_CLIENT_ID=123456789-abcdefgh.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxxxxxx
OAuth Init validates your input - for example, Google Client IDs must contain .apps.googleusercontent.com.

Next steps

Set up more providers

Add GitHub or Discord OAuth

Configure options

Learn about CLI flags and options

Auth libraries

See supported auth libraries

Troubleshooting

Common issues and solutions
app/api/auth/[...nextauth]/route.ts
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google";

export const authOptions = {
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_CLIENT_ID!,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
    }),
  ],
};

const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };

Setting up multiple providers

You can configure multiple OAuth providers in one session:
oauth-init
Select multiple providers using Space:
◆  Select OAuth services to setup:
│  ◉ Google
│  ◉ Github
│  ◉ Discord

OAuth Init will guide you through each provider sequentially.

Non-interactive mode

For CI/CD environments or when you prefer manual browser control:
oauth-init --no-open --quiet
This displays URLs without opening your browser and reduces output verbosity.

Build docs developers (and LLMs) love