mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 06:32:03 +00:00
fix(ai): device-code flow uses OAuth access token directly (v1.4.8 follow-up)
v1.4.8's device-code flow got the user as far as the chatgpt.com approval, but the connect step at the end still failed with: Codex api-key exchange failed (401): "Invalid ID token: missing organization_id" Root cause: the api-key exchange (RFC 8693, swap id_token for an OpenAI API key) requires the id_token to carry an `organization_id` claim. That claim only gets added when the authorize URL is hit with `id_token_add_organizations=true` — which the browser/auth-code flow does, but the device-code flow does NOT (the user types the code on chatgpt.com's own page; we never control the authorize URL). The official Codex CLI handles this by NOT calling the api-key exchange in the device path: it persists the OAuth access_token / refresh_token directly and uses them against `https://chatgpt.com/backend-api/codex/responses` (the Codex backend that bills against the ChatGPT subscription). v1.4.9 does the same. `pollDeviceCode` no longer calls `obtainApiKey`; it returns the raw OAuth access_token instead. New `refreshDeviceTokens()` mirrors that on the refresh path. The provider rewires Codex back through the existing `CodexClient` (bg backend-api), with proactive refresh + on-401 refresh both going through `refreshDeviceTokens`. The browser/auth-code flow path is left in place — operators who register a private OAuth app with OpenAI (e.g. for an enterprise deployment) can still use the api-key exchange via the `exchangeCodeForTokens` helper. For the public Codex client ID on hosted instances, device-code is the only working path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
19eb1d95d6
commit
3dbc8af627
5 files changed
+129
-50
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "healthlog",
|
||||
"version": "1.4.8",
|
||||
"version": "1.4.9",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@10.31.0",
|
||||
"scripts": {
|
||||
|
||||
Reference in new issue
Block a user