This guide walks you through setting up the required credentials for SubTracker.
- Google OAuth (for Gmail login & email scanning)
- Microsoft OAuth (for Outlook login & email scanning)
- OpenAI API Key (optional - for AI-powered subscription detection)
- Go to Google Cloud Console
- Click "Select a project" → "New Project"
- Name it "SubTracker" and create
- Go to "APIs & Services" → "Library"
- Search for "Gmail API" and enable it
- Go to "APIs & Services" → "OAuth consent screen"
- Select "External" user type
- Fill in:
- App name:
SubTracker - User support email: your email
- Developer contact: your email
- App name:
- Add scopes:
emailprofileopenidhttps://www.googleapis.com/auth/gmail.readonly
- Add your email as a test user
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- Application type: "Web application"
- Name: "SubTracker Web"
- Authorized redirect URIs:
http://localhost:3000/api/auth/callback/google(development)https://yourdomain.com/api/auth/callback/google(production)
- Copy the Client ID and Client Secret
GOOGLE_CLIENT_ID="your-client-id.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="your-client-secret"
- Go to Azure Portal
- Search for "App registrations" and click it
- Click "New registration"
- Fill in:
- Name:
SubTracker - Supported account types: "Accounts in any organizational directory and personal Microsoft accounts"
- Redirect URI: Web →
http://localhost:3000/api/auth/callback/microsoft-entra-id
- Name:
- Click "Register"
- On the Overview page, copy the Application (client) ID
- Go to "Certificates & secrets"
- Click "New client secret"
- Description: "SubTracker Auth"
- Expiry: Choose based on your needs
- Copy the Value (not the Secret ID)
- Go to "API permissions"
- Click "Add a permission" → "Microsoft Graph"
- Select "Delegated permissions"
- Add these permissions:
emailopenidprofileUser.ReadMail.Read
- Click "Grant admin consent" if you have admin access
MICROSOFT_CLIENT_ID="your-application-client-id"
MICROSOFT_CLIENT_SECRET="your-client-secret-value"
For AI-powered subscription detection from email content.
- Go to OpenAI Platform
- Sign in or create an account
- Click "Create new secret key"
- Copy the key
OPENAI_API_KEY="sk-your-api-key"
Your .env file should look like this:
# Database
DATABASE_URL="file:./dev.db"
# NextAuth
NEXTAUTH_SECRET="your-random-secret-key-at-least-32-chars"
NEXTAUTH_URL="http://localhost:3000"
# Google OAuth
GOOGLE_CLIENT_ID="your-google-client-id.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
# Microsoft OAuth
MICROSOFT_CLIENT_ID="your-microsoft-application-id"
MICROSOFT_CLIENT_SECRET="your-microsoft-client-secret"
# OpenAI (optional)
OPENAI_API_KEY="sk-your-openai-key"After adding your credentials:
# Install dependencies
npm install
# Run database migrations
npx prisma migrate dev
# Start development server
npm run devVisit http://localhost:3000 and try signing in!
- Make sure your redirect URIs in Google/Microsoft match exactly:
- Google:
http://localhost:3000/api/auth/callback/google - Microsoft:
http://localhost:3000/api/auth/callback/microsoft-entra-id
- Google:
- For Google: Make sure you've added your email as a test user
- For Microsoft: Make sure you've granted admin consent for the permissions
npx prisma migrate reset
npx prisma generate