Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/device-approve-claim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@object-ui/console": patch
---

DeviceAuthPage claims the device code (GET /device?user_code=…) before approve/deny — better-auth's device-authorization plugin rejects both with 400 "not been claimed by a verifying session" otherwise, so approval silently failed.
12 changes: 12 additions & 0 deletions apps/console/src/pages/auth/DeviceAuthPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,21 @@ export function DeviceAuthPage() {
);
}

// better-auth's device-authorization plugin requires the verifying
// session to CLAIM the code (GET /device?user_code=…) before it will
// accept approve/deny — without it both return 400 "not been claimed
// by a verifying session". Idempotent, so claim right before acting.
const claimDevice = async () => {
await fetch(`${AUTH_BASE}/device?user_code=${encodeURIComponent(code)}`, {
credentials: 'include',
}).catch(() => { /* approve below surfaces the real error */ });
};

const handleApprove = async () => {
setError('');
setSubmitting(true);
try {
await claimDevice();
const res = await fetch(`${AUTH_BASE}/device/approve`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -186,6 +197,7 @@ export function DeviceAuthPage() {
setError('');
setDenying(true);
try {
await claimDevice();
await fetch(`${AUTH_BASE}/device/deny`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand Down
Loading