Commit e0fce36
fix: fully stateless OAuth tokens, drop HOMEASSISTANT_TOKEN requirement (homeassistant-ai#893)
* fix: make OAuth tokens fully stateless, drop HOMEASSISTANT_TOKEN requirement
Fixes homeassistant-ai#886: OAuth mode no longer requires HOMEASSISTANT_TOKEN env var.
When the var is empty/unset, main_oauth() sets the sentinel value so
Settings validation passes.
Fixes homeassistant-ai#837: Both access and refresh tokens are now stateless
(base64-encoded JSON containing the HA LLAT, type, client_id, scopes,
and expiry). No server-side token state is stored, eliminating
oauth_state.json and all disk I/O. Tokens survive container restarts
by design — clients re-register via DCR automatically.
Removed: _save_state(), _load_state(), _refresh_to_access_map,
state_dir parameter, get_ha_credentials_for_token().
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: validate json.loads returns dict in _decode_token
json.loads can return non-dict types (list, str, int) for valid JSON.
Without isinstance check, calling .get() on a non-dict payload would
raise AttributeError, which is not in the except clause.
Addresses Gemini Code Assist review feedback on PR homeassistant-ai#893.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: kingpanther13 <kingpanther13@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 09f4b69 commit e0fce36
4 files changed
Lines changed: 579 additions & 672 deletions
File tree
- .github/workflows
- src/ha_mcp
- auth
- tests/src/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
42 | 76 | | |
43 | 77 | | |
44 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
610 | 612 | | |
611 | 613 | | |
612 | 614 | | |
613 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
614 | 618 | | |
615 | 619 | | |
616 | 620 | | |
| |||
710 | 714 | | |
711 | 715 | | |
712 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
713 | 726 | | |
714 | 727 | | |
715 | 728 | | |
| |||
791 | 804 | | |
792 | 805 | | |
793 | 806 | | |
794 | | - | |
795 | | - | |
796 | | - | |
| 807 | + | |
797 | 808 | | |
798 | 809 | | |
799 | 810 | | |
| |||
0 commit comments