From c03702cf1337f13d53f14ea0e7e18550d144d1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Wadstr=C3=B6m?= Date: Tue, 4 Nov 2025 11:23:04 +0100 Subject: [PATCH] fix: make token type comparison case-insensitive in authentication The Zaptec API returns token_type as "bearer" (lowercase), but the code was checking for exactly "Bearer" (uppercase), causing authentication to fail. Changed the comparison to be case-insensitive using toLowerCase(). Also fixed the error message which was incorrectly showing data.token_type twice instead of displaying the expected value "Bearer". --- lib/zaptec/api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/zaptec/api.ts b/lib/zaptec/api.ts index 68c34da..20b02f8 100644 --- a/lib/zaptec/api.ts +++ b/lib/zaptec/api.ts @@ -342,9 +342,9 @@ export class ZaptecApi { ); if (response.statusCode === 200) { - if (data.token_type !== 'Bearer') { + if (data.token_type.toLowerCase() !== 'bearer') { throw new Error( - `Invalid token type received ${data.token_type}, expected ${data.token_type}`, + `Invalid token type received ${data.token_type}, expected Bearer`, ); }