[PR #5451] [MERGED] feat: redesign device authorization api #6017

Closed
opened 2026-03-13 12:44:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5451
Author: @bytaesu
Created: 10/21/2025
Status: Merged
Merged: 11/20/2025
Merged by: @himself65

Base: canaryHead: 2025-10-21/feat/redesign-device-authorization-flow


📝 Commits (10+)

  • 7106bf6 refactor: separate error codes, infer types
  • cb3f952 feat: redesign verification api for device authorization plugin
  • df45dab test: adjust test cases for new api
  • 9b912ac chore: cleanup comment
  • e8c8576 fix: import
  • c2158a6 type: fix
  • 2bd1db8 docs: add verificationUri option guide to device authorization plugin
  • 60553c7 Merge branch 'canary' into 2025-10-21/feat/redesign-device-authorization-flow
  • 70e3dec chore: lint
  • 4cb9b0e Merge branch 'canary' into 2025-10-21/feat/redesign-device-authorization-flow

📊 Changes

4 files changed (+223 additions, -82 deletions)

View changed files

📝 docs/content/docs/plugins/device-authorization.mdx (+9 -7)
📝 packages/better-auth/src/plugins/device-authorization/device-authorization.test.ts (+137 -19)
packages/better-auth/src/plugins/device-authorization/error-codes.ts (+16 -0)
📝 packages/better-auth/src/plugins/device-authorization/index.ts (+61 -56)

📄 Description

This PR adds a verificationUri option to the Device Authorization Plugin and updates the related APIs and test cases accordingly.

Problem:

  • Although there’s a commented plan to serve an HTML page, unlike an error page, this page involves multiple steps such as verification, redirection, and additional API calls. Therefore, serving a static HTML directly from the backend is not appropriate.

Solution:

  • Expose verificationUri as an option so that teams can specify their own frontend endpoint.
  • This allows teams to build their own verification page to handle authentication checks, approval/rejection flows, and any other logic according to their needs.

Summary by cubic

Redesigned the device authorization flow to let teams host their own verification page via a new verificationUri option. The API now returns verification URLs from this option or defaults to /device.

  • New Features

    • Added verificationUri option (absolute URL or relative path) to build verification_uri and verification_uri_complete.
    • Defaults to /device when not configured; supports existing query params and includes user_code.
    • OpenAPI updated with uri format and clearer descriptions.
  • Migration

    • Renamed $deviceAuthorizationOptionsSchema to deviceAuthorizationOptionsSchema.
    • Responses always include verification_uri and verification_uri_complete (default /device); set verificationUri to customize.
    • The verification endpoint documents JSON status; teams should implement their own UI at verificationUri.
    • deviceAuthorizationClient is no longer re-exported; import it from the client module directly.

Written for commit c7b772009d. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5451 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 10/21/2025 **Status:** ✅ Merged **Merged:** 11/20/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2025-10-21/feat/redesign-device-authorization-flow` --- ### 📝 Commits (10+) - [`7106bf6`](https://github.com/better-auth/better-auth/commit/7106bf6d1f229c9d7d18566ce72379554ec29d6b) refactor: separate error codes, infer types - [`cb3f952`](https://github.com/better-auth/better-auth/commit/cb3f952160e02d42cfb0bb9671c439cf8e1368d5) feat: redesign verification api for device authorization plugin - [`df45dab`](https://github.com/better-auth/better-auth/commit/df45dabd714b73e202f0d0baf70150e5664e8515) test: adjust test cases for new api - [`9b912ac`](https://github.com/better-auth/better-auth/commit/9b912ac70a234919889939260fed87773c79dce8) chore: cleanup comment - [`e8c8576`](https://github.com/better-auth/better-auth/commit/e8c85761f8e5dc7479a9d380505600777ae6fe74) fix: import - [`c2158a6`](https://github.com/better-auth/better-auth/commit/c2158a684a37ba38090408252e070a6125be753b) type: fix - [`2bd1db8`](https://github.com/better-auth/better-auth/commit/2bd1db8dfa61dc4071ef264cd3625aa9f3cbdb5a) docs: add verificationUri option guide to device authorization plugin - [`60553c7`](https://github.com/better-auth/better-auth/commit/60553c7508f024808a84700897f6e02ba0d058da) Merge branch 'canary' into 2025-10-21/feat/redesign-device-authorization-flow - [`70e3dec`](https://github.com/better-auth/better-auth/commit/70e3dec03986f763db323787c0c711aefff6c7eb) chore: lint - [`4cb9b0e`](https://github.com/better-auth/better-auth/commit/4cb9b0e7acf1f63644b62879716052c602d269b5) Merge branch 'canary' into 2025-10-21/feat/redesign-device-authorization-flow ### 📊 Changes **4 files changed** (+223 additions, -82 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/device-authorization.mdx` (+9 -7) 📝 `packages/better-auth/src/plugins/device-authorization/device-authorization.test.ts` (+137 -19) ➕ `packages/better-auth/src/plugins/device-authorization/error-codes.ts` (+16 -0) 📝 `packages/better-auth/src/plugins/device-authorization/index.ts` (+61 -56) </details> ### 📄 Description This PR adds a `verificationUri` option to the Device Authorization Plugin and updates the related APIs and test cases accordingly. ### Problem: - Although there’s a commented plan to serve an HTML page, unlike an error page, this page involves multiple steps such as verification, redirection, and additional API calls. Therefore, serving a static HTML directly from the backend is not appropriate. ### Solution: - Expose verificationUri as an option so that teams can specify their own frontend endpoint. - This allows teams to build their own verification page to handle authentication checks, approval/rejection flows, and any other logic according to their needs. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Redesigned the device authorization flow to let teams host their own verification page via a new verificationUri option. The API now returns verification URLs from this option or defaults to /device. - **New Features** - Added verificationUri option (absolute URL or relative path) to build verification_uri and verification_uri_complete. - Defaults to /device when not configured; supports existing query params and includes user_code. - OpenAPI updated with uri format and clearer descriptions. - **Migration** - Renamed $deviceAuthorizationOptionsSchema to deviceAuthorizationOptionsSchema. - Responses always include verification_uri and verification_uri_complete (default /device); set verificationUri to customize. - The verification endpoint documents JSON status; teams should implement their own UI at verificationUri. - deviceAuthorizationClient is no longer re-exported; import it from the client module directly. <sup>Written for commit c7b772009dc5de810d29f5c3744c48549d2b8558. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:44:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#6017