raylib: fix pairing url

master
Shane Smiskol 15 hours ago
parent c7a9ea2bf4
commit d05cb31e2e
  1. 4
      common/api.py
  2. 4
      selfdrive/ui/widgets/pairing_dialog.py

@ -22,7 +22,7 @@ class Api:
def request(self, method, endpoint, timeout=None, access_token=None, **params):
return api_get(endpoint, method=method, timeout=timeout, access_token=access_token, **params)
def get_token(self, expiry_hours=1):
def get_token(self, payload_extra=None, expiry_hours=1):
now = datetime.now(UTC).replace(tzinfo=None)
payload = {
'identity': self.dongle_id,
@ -30,6 +30,8 @@ class Api:
'iat': now,
'exp': now + timedelta(hours=expiry_hours)
}
if payload_extra is not None:
payload.update(payload_extra)
token = jwt.encode(payload, self.private_key, algorithm='RS256')
if isinstance(token, bytes):
token = token.decode('utf8')

@ -24,11 +24,11 @@ class PairingDialog:
def _get_pairing_url(self) -> str:
try:
dongle_id = self.params.get("DongleId") or ""
token = Api(dongle_id).get_token()
token = Api(dongle_id).get_token({'pair': True})
except Exception as e:
cloudlog.warning(f"Failed to get pairing token: {e}")
token = ""
return f"https://connect.comma.ai/setup?token={token}"
return f"https://connect.comma.ai/?pair={token}"
def _generate_qr_code(self) -> None:
try:

Loading…
Cancel
Save