Overview
The GitHub integration allows you to:- Connect your GitHub account via OAuth
- Sync and analyze repositories
- Audit blog content directly from GitHub repos
- Create pull requests with automated SEO/GEO fixes
- Monitor PR status and webhook events
OAuth Setup Workflow
Request Authorization URL
Call the Response:The
/api/github/auth-url endpoint with your JWT bearer token:state parameter is a signed, time-limited token (valid for 10 minutes) that prevents CSRF attacks.Redirect User to GitHub
Redirect your user to the returned
url. They’ll authorize your app to access their GitHub account.Handle OAuth Callback
GitHub redirects back with a Response:
code and state. Post these to /api/github/callback:OAuth Security Contract
Security Features
- User binding: State tokens are tied to the authenticated user
- Time-limited: Tokens expire after 10 minutes
- Signature verification: HMAC-SHA256 prevents tampering
- Cross-user protection: Callbacks validate the user matches the original requester
Connecting GitHub Accounts
List Connections
Retrieve all active GitHub connections for the authenticated user:Sync Repositories
Manually sync repositories for a connection:Get Repositories
List all synced repositories:Blog Content Auditing
Analyze Repository
Detect the site framework and structure:Audit All Blogs
Run a comprehensive SEO audit on all blog posts:- Detects all blog files based on the framework (Next.js, Gatsby, Hugo, etc.)
- Analyzes each post for SEO issues
- Returns a detailed report with issues per blog
Audit with GEO (Generative Engine Optimization)
For advanced LLM optimization:- Q&A format optimization (LLMs prefer question-answer structure)
- E-E-A-T signals (Experience, Expertise, Authority, Trust)
- Snippet-level clarity
- Conversational language vs keyword stuffing
- Direct answer formatting (inverted pyramid)
Creating Pull Requests with Fixes
From Blog Audits
Create a PR with automated fixes for specific blogs:With GEO Fixes
Include both SEO and GEO optimizations:From Existing Audits
Create a PR based on a completed site audit:Before creating a PR, ensure all required fix inputs are provided. Use
/api/github/fix-inputs/{audit_id} to check for missing inputs.List Pull Requests
Get all PRs created for a repository:Fix Input Management
Check Required Inputs
Before creating automated PRs, check if user input is needed:Submit Fix Inputs
Provide missing information:AI-Assisted Input Chat
Get LLM suggestions for missing inputs based on audit evidence:Webhook Events
LatentGEO can receive GitHub webhooks to automate workflows. See the Webhooks page for setup details.
push: Auto-audit when code is pushed (ifauto_auditis enabled)pull_request: Update PR status in the databaseinstallation: Handle GitHub App installation/uninstallation
Webhook Endpoint
X-GitHub-Event: Event type (push, pull_request, etc.)X-Hub-Signature-256: HMAC-SHA256 signature for verification
Auto-Audit Configuration
Enable automatic audits when code is pushed:auto_audit: Trigger audit on push eventsauto_pr: Automatically create PRs with fixes (coming soon)
Common Errors
401 Unauthorized
- Missing or invalid JWT token
- OAuth state token expired or tampered with
- User mismatch between OAuth start and callback
403 Forbidden
- Attempting to access another user’s connection
- Legacy ownerless connection in production mode
404 Not Found
- Repository or connection not found
- PR not found
422 Unprocessable Entity
- Missing required fix inputs
- Use
/api/github/fix-inputs/{audit_id}to resolve
Best Practices
- Always validate state tokens: Never skip the state parameter in OAuth flows
- Check for required inputs: Before creating PRs, call the fix-inputs endpoint
- Use GEO audits for content sites: Blogs and content marketing benefit most from GEO optimization
- Monitor webhook health: Set up
/webhooks/healthmonitoring - Review PRs before merging: Automated fixes should always be reviewed by humans
Next Steps
Webhooks
Set up webhook integrations for automation
HubSpot Integration
Connect HubSpot to apply SEO fixes directly