Overview
Reportr integrates with three Google APIs to generate comprehensive SEO reports:- Google Search Console API - Search performance and keyword data
- Google Analytics 4 API - User behavior and traffic metrics
- PageSpeed Insights API - Core Web Vitals and performance scores
Prerequisites
- A Google Cloud Platform account
- Admin access to your deployment environment variables
- Domain verification (for production deployment)
Step 1: Create a Google Cloud Project
Access Google Cloud Console
Navigate to Google Cloud Console and sign in with your Google account.
Create a new project
- Click the project dropdown in the top navigation
- Click New Project
- Enter a project name (e.g., “Reportr Production”)
- Click Create
Step 2: Enable Required APIs
Enable Google Search Console API
- Search for “Google Search Console API”
- Click on the result
- Click Enable
Enable Google Analytics Data API
- Search for “Google Analytics Data API”
- Click on the result
- Click Enable
You need the Data API v1, not the older Reporting API.
Step 3: Configure OAuth Consent Screen
Choose user type
- Internal: Only for Google Workspace organizations
- External: For public SaaS (choose this for most deployments)
Fill in app information
App information:
- App name:
Your Agency Name - Reportr - User support email: Your support email
- Developer contact: Your email
- Application home page:
https://yourdomain.com - Privacy policy:
https://yourdomain.com/privacy - Terms of service:
https://yourdomain.com/terms
Add required scopes
Click Add or Remove Scopes and add these scopes:These match the scopes defined in
/workspace/source/src/lib/google/config.ts:3-6Click Save and ContinueStep 4: Create OAuth 2.0 Credentials
Create OAuth Client ID
- Click Create Credentials → OAuth client ID
- Application type: Web application
- Name:
Reportr OAuth Client
Configure authorized redirect URIs
Add your callback URLs:For local development:For production:Click Create
This matches the redirect URI in
/workspace/source/src/app/api/auth/google/authorize/route.ts:17-22Step 5: Create PageSpeed Insights API Key
Create API key
- Go to APIs & Services → Credentials
- Click Create Credentials → API key
- Copy the generated API key
Step 6: Configure Environment Variables
Add the credentials to your.env file:
Rate Limits and Quotas
Reportr is configured with the following API rate limits (see/workspace/source/src/lib/google/config.ts:34-48):
| API | Requests/Minute | Requests/Day |
|---|---|---|
| Search Console | 100 | 1,000 |
| Analytics 4 | 100 | 50,000 |
| PageSpeed Insights | 25 | 25,000 |
Verification and Testing
Verify API access
Check that all three APIs show as “Enabled” in your Google Cloud Console:APIs & Services → Enabled APIs & services
Test OAuth flow
- Start your development server:
npm run dev - Sign in to Reportr
- Navigate to Dashboard → Clients
- Add a client and click Connect Google Account
- You should see the Google OAuth consent screen
Troubleshooting
”Redirect URI mismatch” Error
Problem: OAuth callback fails with redirect URI error Solution:- Verify the redirect URI in Google Cloud Console exactly matches your
GOOGLE_REDIRECT_URI - Ensure there are no trailing slashes
- Check that
NEXTAUTH_URLis set correctly - Restart your development server after changing environment variables
”Access Denied” During OAuth
Problem: Users see “This app isn’t verified” or access is denied Solution:- For development: Add users as test users in OAuth consent screen
- For production: Complete the app verification process with Google
API Quota Exceeded
Problem: Report generation fails with quota errors Solution:- Check current quota usage in APIs & Services → Dashboard
- Request quota increases for production workloads
- Implement caching to reduce API calls (future enhancement)
Missing Scopes Error
Problem: API calls fail with insufficient permissions Solution:- Verify scopes in OAuth consent screen match those in
config.ts - Have users re-authorize their connection to grant new scopes
- Check that the correct scopes are being requested in the OAuth flow
Security Best Practices
- Rotate credentials if they’re ever exposed
- Use API restrictions on your PageSpeed API key
- Enable Cloud Audit Logs to monitor API usage
- Set up quota alerts to catch unusual usage patterns
Next Steps
Once your Google APIs are configured:Connect Clients
Learn how to connect client websites to Google APIs
Generate Reports
Start creating AI-powered SEO reports