From 79c50488fefa1ad98790f7a7bfd1c6320587af8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Gran=C3=A1t?= Date: Mon, 24 Feb 2025 11:47:20 +0100 Subject: [PATCH 1/2] fix: improve invalid api key error --- src/client/getApiKeyInformation.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/getApiKeyInformation.ts b/src/client/getApiKeyInformation.ts index 37477ad..ca37118 100644 --- a/src/client/getApiKeyInformation.ts +++ b/src/client/getApiKeyInformation.ts @@ -34,7 +34,9 @@ export const getApiKeyInformation = async ( if (key.startsWith(API_KEY_PAK_PREFIX)) { const loadable = await client.GET('/v2/api-keys/current'); if (loadable.response.status === 401) { - exitWithError("Couldn't log in: the API key you provided is invalid."); + exitWithError( + `Couldn't log in: the API key you provided is invalid (${new URL(loadable.response.url).host}).` + ); } handleLoadableError(loadable); @@ -54,7 +56,9 @@ export const getApiKeyInformation = async ( } else { const loadable = await client.GET('/v2/pats/current'); if (loadable.response.status === 401) { - exitWithError("Couldn't log in: the API key you provided is invalid."); + exitWithError( + `Couldn't log in: the API key you provided is invalid (${new URL(loadable.response.url).host}).` + ); } handleLoadableError(loadable); From b39781d7e19d2cc8839affb23437d906374f8234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Gran=C3=A1t?= Date: Mon, 24 Feb 2025 13:28:33 +0100 Subject: [PATCH 2/2] fix: improve invalid api key error --- src/client/ApiClient.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/ApiClient.ts b/src/client/ApiClient.ts index 629740d..41cb779 100644 --- a/src/client/ApiClient.ts +++ b/src/client/ApiClient.ts @@ -99,6 +99,9 @@ export function createApiClient({ getApiKeyInfo() { return getApiKeyInformation(apiClient, apiKey!); }, + getSettings(): ApiClientProps { + return { baseUrl, apiKey, projectId, autoThrow }; + }, }; }