Skip to main content

Google Login

Nextfast comes with pre configured google login can be found in auth.config.ts.

Make sure you have setup the .env correctly with

# http://localhost:3000 for local development
NEXT_PUBLIC_APP_URL="http://localhost:3000"

# run `npx auth secret` or go to https://generate-secret.now.sh/32
AUTH_SECRET=y+u8yfKbffzeOOuobao1/B0FgsblDOwpsL2y0XTzt7x=

GOOGLE_CLIENT_ID=<your_client_id></your_client_id>
GOOGLE_CLIENT_SECRET=<your_client_secret>

Steps to generate Google Client & Secret

  1. Create a new project on Google Cloud

  2. In the Google Cloud Console, navigate to the "APIs & Services" > "Library" section.

  3. Search for the API you want to enable (e.g., Google Drive API, Gmail API).

  4. Click on the API you want to use.

  5. Click the "Enable" button.

  6. In the Google Cloud Console, navigate to the "APIs & Services" > "OAuth consent screen" section.

  7. Choose whether your application is internal or external.

  8. Fill in the required fields like "Application Name" and "Authorized domains".

  9. Optionally, you can add scopes and additional information.

  10. Click "Save and Continue".

  11. In the Google Cloud Console, navigate to the "APIs & Services" > "Credentials" section.

  12. Click on the "Create Credentials" dropdown and select "OAuth client ID".

  13. Choose the application type (Web application) for our use case.

  14. Enter a name for your OAuth client ID.

  15. Add http://localhost:3000/api/auth/callback/google and https://your-site.com/api/auth/callback/google to Authorized redirect URIs

  16. Copy paste the Client ID in GOOGLE_CLIENT_ID and Client Secret in GOOGLE_CLIENT_SECRET to .env.