๐ 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
-
Open Google Cloud Consoleย .
-
Create a new project or select an existing one.
๐ Note: The project selector is next to the Google Cloud logo at the top left.
-
Ensure the correct project is selected from the dropdown.
-
Navigate to APIs & Services โ Credentials in the sidebar.
Or use this direct link: Google Cloud Console โ APIs & Services โ Credentialsย
-
Click + CREATE CREDENTIALS โ OAuth client ID.
If prompted, configure the Consent Screen first by clicking CONFIGURE CONSENT SCREEN and following the instructions.
-
Select Web application as the application type.
-
Fill in the required details, e.g., client name.
-
Configure Authorized Redirect URIs
- Add the following URI for local development:
http://localhost:3000/api/auth/callback/google๐ก For production, replace
localhost:3000with 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
- Start your development server:
pnpm dev- Go to http://localhost:3000/signinย
- You should see Google as a login option.
- 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.