Skip to content

feat(auth): Google + GitHub OAuth on device-flow sign-in - #4

Merged
Codehagen merged 1 commit into
mainfrom
feat/oauth-providers
Apr 17, 2026
Merged

Codehagen merged 1 commit into
mainfrom
feat/oauth-providers

Conversation

@Codehagen

@Codehagen Codehagen commented Apr 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Opt-in Google + GitHub buttons on /device above the existing magic-link form
  • Providers register into Better Auth's socialProviders only when both *_CLIENT_ID and *_CLIENT_SECRET are present in env; missing env → button hidden, magic-link still works
  • Hoped for TTHW: cold-path login drops from ~60s (email round-trip) to ~20s (one-click OAuth) once the OAuth apps are configured

Rollout (blocked on manual OAuth app creation)

Google Cloud Console → APIs & Services → Credentials → Create Credentials → OAuth client ID

  • Application type: Web application
  • Authorized redirect URI: https://helpbase.dev/api/auth/callback/google
  • Also add http://localhost:3000/api/auth/callback/google for dev

GitHub → Settings → Developer settings → OAuth Apps → New OAuth App

  • Homepage URL: https://helpbase.dev
  • Authorization callback URL: https://helpbase.dev/api/auth/callback/github

Once the OAuth apps exist, set in Vercel (Production + Preview):

  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET
  • GITHUB_CLIENT_ID
  • GITHUB_CLIENT_SECRET

No DB migration required.

Test plan

  • Vercel preview deploy green
  • Preview /device shows only the existing magic-link form (no OAuth env set yet → buttons hidden by design)
  • After adding OAuth env in Vercel + merging, /device on prod shows the Google + GitHub buttons
  • Cold CLI login: rm ~/.helpbase/auth.json && helpbase login → click "Continue with Google" → bounced back to /device?user_code=… signed in → Authorize → terminal picks up bearer
  • Same end-to-end for GitHub
  • Magic-link path still works if you click the email input

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added Google and GitHub OAuth sign-in options to the device authorization page as faster alternatives to email magic-link login.
    • Email sign-in remains available as a fallback option.
    • OAuth providers are opt-in and configured via environment variables for deployments.

Opt-in social providers render above the magic-link form when the
server has {GOOGLE,GITHUB}_CLIENT_{ID,SECRET} configured. Providers
are wired into Better Auth's `socialProviders` only when both values
are present — missing env just hides the button, magic-link stays
available as fallback.

- lib/auth.ts: `authProviders` boolean map + `buildSocialProviders()`
- device/page.tsx: resolves provider availability server-side and
  passes it to the client so buttons don't flash in before hydration
- device/AuthorizeDeviceClient.tsx: Continue-with-Google/-GitHub
  buttons, inline SVG icons, shared disabled state with the email
  form
- .env.example: documents redirect URIs + console locations for each
  provider (Google Cloud Console, GitHub Developer Settings)
- CHANGELOG: unreleased entry

Vercel preview auto-deploys on push; prod picks it up once the PR
merges + OAuth apps exist in the consoles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
helpbase Ready Ready Preview, Comment Apr 17, 2026 6:34pm

Request Review

@coderabbitai

coderabbitai Bot commented Apr 17, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added optional OAuth sign-in capability (Google and GitHub) to the device authorization flow. Changes include environment configuration documentation, backend OAuth provider setup in Better Auth, updated device authorization UI component with social sign-in buttons, and provider availability wiring through the page component.

Changes

Cohort / File(s) Summary
Documentation & Configuration
CHANGELOG.md, apps/web/.env.example
Added documentation for new Google and GitHub OAuth environment variables and feature announcement of conditional OAuth sign-in buttons on /device page with email fallback.
OAuth Provider Setup
apps/web/lib/auth.ts
Introduced authProviders constant that conditionally enables Google/GitHub based on env vars; added buildSocialProviders() helper and wired socialProviders into Better Auth initialization.
Device Authorization UI
apps/web/app/device/AuthorizeDeviceClient.tsx, apps/web/app/device/page.tsx
Added ProviderAvailability interface; updated component to accept providers prop; implemented socialSubmitting state and handleSocialSignIn() handler with callback URL construction including user_code; added social provider buttons with Google/GitHub icons; updated email button disable logic to account for social sign-in state; wired provider availability from server to component.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant AC as AuthorizeDeviceClient
    participant authClient as authClient<br/>(Better Auth)
    participant OAuth as OAuth Provider<br/>(Google/GitHub)
    
    User->>AC: Clicks "Continue with Google/GitHub"
    AC->>AC: Set socialSubmitting state
    AC->>authClient: signIn.social({<br/>provider,<br/>callbackURL: /device?user_code=...
    Note over authClient: Constructs auth request<br/>with provider & callback
    authClient->>OAuth: Redirect to provider
    User->>OAuth: Authenticates & consents
    OAuth->>authClient: Callback to /device?user_code=...
    authClient->>AC: Sign-in success
    AC->>AC: Clear socialSubmitting<br/>Update auth state
    AC->>User: Render signed-in state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hop, click, and OAuth in style—
Google and GitHub join the device auth file!
With user codes passed through the callback so bright,
Social sign-in buttons now authorize just right. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding opt-in Google and GitHub OAuth sign-in buttons to the device-flow authentication page.
Description check ✅ Passed The description covers the core functionality (opt-in OAuth buttons above magic-link), environment variable requirements, expected performance improvement, and detailed rollout and testing instructions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/oauth-providers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/web/app/device/AuthorizeDeviceClient.tsx (1)

335-363: Optional: extract inline SVG icons to separate files.

The icon components add ~30 lines of markup to an already-large client component. Consider moving GoogleIcon / GitHubIcon to apps/web/components/icons/ (or similar) for reuse if a future sign-in surface needs them. Non-blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/app/device/AuthorizeDeviceClient.tsx` around lines 335 - 363,
Extract the inline SVGs into standalone icon components: move the GoogleIcon and
GitHubIcon JSX into their own component modules (e.g., exportable GoogleIcon and
GitHubIcon components), replace the inline functions in
AuthorizeDeviceClient.tsx with imports of those components, and update any
imports/exports accordingly so the sign-in UI reuses the icons without inflating
the main client component.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/web/app/device/AuthorizeDeviceClient.tsx`:
- Around line 335-363: Extract the inline SVGs into standalone icon components:
move the GoogleIcon and GitHubIcon JSX into their own component modules (e.g.,
exportable GoogleIcon and GitHubIcon components), replace the inline functions
in AuthorizeDeviceClient.tsx with imports of those components, and update any
imports/exports accordingly so the sign-in UI reuses the icons without inflating
the main client component.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cf443111-b52a-4f71-bcc7-726cc5b715b6

📥 Commits

Reviewing files that changed from the base of the PR and between 726a0fd and e68874f.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • apps/web/.env.example
  • apps/web/app/device/AuthorizeDeviceClient.tsx
  • apps/web/app/device/page.tsx
  • apps/web/lib/auth.ts

@Codehagen
Codehagen merged commit e769fa1 into main Apr 17, 2026
5 checks passed
@Codehagen
Codehagen deleted the feat/oauth-providers branch April 17, 2026 18:40

This branch was successfully deployed

1 active deployment
Preview — e68874f3 Deployed Apr 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant