From dca4bc40c0d65f4a161427506fb80bb8316f123a Mon Sep 17 00:00:00 2001 From: Dan Jarvis Date: Wed, 12 Jul 2023 13:19:09 -0500 Subject: [PATCH] feat: Allow custom accessKey on console api (#216) --- api-request.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api-request.js b/api-request.js index abb1312..9d1aa37 100644 --- a/api-request.js +++ b/api-request.js @@ -20,9 +20,13 @@ module.exports = async (pathname, options = {}) => { const authMethod = options.noAuth ? 'none' : await resolveAuthMethod(); if (!authMethod) throw new Error('Not authenticated to send request to the Console server'); const requestId = ++requestIdCounter; - const authorization = options.noAuth - ? {} - : { Authorization: `Bearer ${await resolveAuthToken()}` }; + let authorization = {}; + if (!options.noAuth && !options.accessKey) { + authorization = { Authorization: `Bearer ${await resolveAuthToken()}` }; + } else if (!options.noAuth && options.accessKey) { + authorization = { Authorization: `Bearer ${options.accessKey}` }; + } + const response = await (async () => { const url = `${urls[options.urlName] || urls.backend}${pathname}`; const headers = {