Skip to Content
Get StartedAuthentication Setup

๐ŸŒ Setting Up Google OAuth

To enable Google login in your project, you need a Client ID and Client Secret from Google.
Follow these steps carefully.


1. Go to Google Cloud Console

  1. Open Google Cloud Consoleย .

  2. Create a new project or select an existing one.

    ๐Ÿ“ Note: The project selector is next to the Google Cloud logo at the top left.

  3. Ensure the correct project is selected from the dropdown.

  4. Navigate to APIs & Services โ†’ Credentials in the sidebar.

    Or use this direct link: Google Cloud Console โ†’ APIs & Services โ†’ Credentialsย 

  5. Click + CREATE CREDENTIALS โ†’ OAuth client ID.

    If prompted, configure the Consent Screen first by clicking CONFIGURE CONSENT SCREEN and following the instructions.

  6. Select Web application as the application type.

  7. Fill in the required details, e.g., client name.

  8. Configure Authorized Redirect URIs

  • Add the following URI for local development:
http://localhost:3000/api/auth/callback/google

๐Ÿ’ก For production, replace localhost:3000 with your live domain.

  • Click Create.
  • Copy the Client ID and Client Secret.

2. Update Your .env

Open your .env file and add the Google credentials:

AUTH_GOOGLE_ID="your_google_client_id_here" AUTH_GOOGLE_SECRET="your_google_client_secret_here"

3. Generate AUTH_SECRET

Auth.js requires a secure secret for encrypting sessions and JWTs.

  • Using Node.js:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

Open your .env file and add the Google credentials:

AUTH_SECRET="paste_your_generated_secret_here"

4. Verify Login

  1. Start your development server:
pnpm dev
  1. Go to http://localhost:3000/signinย 
  2. You should see Google as a login option.
  3. Click it to test that authentication works correctly.

    Note: If you see error in the console about redis and the rate limit, ignore it for now. We will set up upstash in the next steps.

Last updated on