Skip to content

Commit e32c88e

Browse files
authored
Merge pull request #14 from LykosAI/oauth-device-code-flow
2 parents f873aec + df71a8d commit e32c88e

17 files changed

Lines changed: 836 additions & 29 deletions

docs/authentication.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The key name and placement are fully configurable, so this works with APIs that
7575

7676
## OAuth 2.0
7777

78-
LitePost supports three OAuth 2.0 grant types. Each grant type is suited to a different scenario -- choose the one that matches your API's requirements.
78+
LitePost supports four OAuth 2.0 grant types. Each grant type is suited to a different scenario -- choose the one that matches your API's requirements.
7979

8080
### Common Fields
8181

@@ -177,6 +177,29 @@ grant_type=password&username=jane&password=s3cret&client_id=my-app&client_secret
177177
The Password Grant sends user credentials directly to the token endpoint. Only use this with trusted authorization servers over HTTPS. Many providers have deprecated this grant type in favor of Authorization Code with PKCE.
178178
:::
179179

180+
### Device Code
181+
182+
Use this grant type (RFC 8628, the "device flow") when you want a user sign-in without registering a redirect URI. There is no callback at all: the provider hands out a short code, you approve it in the browser, and LitePost polls until the token is ready. This makes it the quickest flow to set up against providers that support it -- GitHub, Microsoft Entra, Google, Auth0, and Okta among them.
183+
184+
**Additional fields:**
185+
186+
| Field | Description |
187+
|--------------------------|-----------------------------------------------------------|
188+
| Device Authorization URL | The provider's device authorization endpoint (e.g. GitHub's `https://github.com/login/device/code`). Auto-fill discovers it from `device_authorization_endpoint` when the provider advertises one. |
189+
190+
**How it works:**
191+
192+
1. Click **Get Access Token**. LitePost asks the Device Authorization URL for a device code.
193+
2. LitePost shows the short user code (like `WDJB-MJHT`) with a copy button, and opens the provider's verification page in your browser.
194+
3. Enter the code (some providers pre-fill it) and approve the sign-in.
195+
4. LitePost polls the Token URL in the background -- honoring the provider's polling interval and `slow_down` responses -- and stores the access token the moment the approval lands.
196+
197+
The code expires after a provider-chosen lifetime (typically 15 minutes); **Cancel** stops the wait early. Client Secret is usually not needed -- device flow clients are public clients.
198+
199+
::: tip
200+
Make sure the device flow is enabled for your OAuth app -- some providers (GitHub, Entra) require opting in per application before the device authorization endpoint will accept your client ID.
201+
:::
202+
180203
### Token Management
181204

182205
Once a token is obtained through any OAuth flow, LitePost handles it as follows:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "litepost",
33
"private": true,
4-
"version": "0.3.1",
4+
"version": "0.4.0",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "litepost"
3-
version = "0.3.1"
3+
version = "0.4.0"
44
description = "A Tauri App"
55
authors = ["you"]
66
edition = "2021"

src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub fn run() {
4040
streaming::cancel_stream,
4141
oauth::oauth2_token_exchange,
4242
oauth::oauth2_auth_code_flow,
43+
oauth::oauth2_device_flow,
4344
oauth::oauth2_cancel_flow,
4445
oauth::oauth2_refresh,
4546
websocket::ws_connect,

0 commit comments

Comments
 (0)