Repository navigation
feat(auth): Google + GitHub OAuth on device-flow sign-in - #4
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdded 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 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/GitHubIcontoapps/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
📒 Files selected for processing (5)
CHANGELOG.mdapps/web/.env.exampleapps/web/app/device/AuthorizeDeviceClient.tsxapps/web/app/device/page.tsxapps/web/lib/auth.ts
Summary
/deviceabove the existing magic-link formsocialProvidersonly when both*_CLIENT_IDand*_CLIENT_SECRETare present in env; missing env → button hidden, magic-link still worksRollout (blocked on manual OAuth app creation)
Google Cloud Console → APIs & Services → Credentials → Create Credentials → OAuth client ID
https://helpbase.dev/api/auth/callback/googlehttp://localhost:3000/api/auth/callback/googlefor devGitHub → Settings → Developer settings → OAuth Apps → New OAuth App
https://helpbase.devhttps://helpbase.dev/api/auth/callback/githubOnce the OAuth apps exist, set in Vercel (Production + Preview):
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGITHUB_CLIENT_IDGITHUB_CLIENT_SECRETNo DB migration required.
Test plan
/deviceshows only the existing magic-link form (no OAuth env set yet → buttons hidden by design)/deviceon prod shows the Google + GitHub buttonsrm ~/.helpbase/auth.json && helpbase login→ click "Continue with Google" → bounced back to/device?user_code=…signed in → Authorize → terminal picks up bearer🤖 Generated with Claude Code
Summary by CodeRabbit