Files
sunnypilot/tools/lib/auth_config.py
T
github-actions[bot] 597bbbb9ee sunnypilot v2026.002.000
version: sunnypilot v2026.002.000 (staging)
date: 2026-07-16T09:36:08
master commit: 48a5bdc8e4
2026-07-16 09:36:08 +00:00

30 lines
623 B
Python

import json
import os
from openpilot.system.hardware.hw import Paths
class MissingAuthConfigError(Exception):
pass
def get_token():
try:
with open(os.path.join(Paths.config_root(), 'auth.json')) as f:
auth = json.load(f)
return auth['access_token']
except Exception:
return None
def set_token(token):
os.makedirs(Paths.config_root(), exist_ok=True)
with open(os.path.join(Paths.config_root(), 'auth.json'), 'w') as f:
json.dump({'access_token': token}, f)
def clear_token():
try:
os.unlink(os.path.join(Paths.config_root(), 'auth.json'))
except FileNotFoundError:
pass