raylib: fix pairing url

This commit is contained in:
Shane Smiskol
2025-09-18 17:03:16 -07:00
parent c7a9ea2bf4
commit d05cb31e2e
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -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')
+2 -2
View File
@@ -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: