@@ -128,15 +128,18 @@ export class ApiClient {
128128 url . searchParams . append ( 'limit' , limit . toString ( ) ) ;
129129 url . searchParams . append ( 'offset' , offset . toString ( ) ) ;
130130
131- // Get API key from localStorage
131+ // Get authentication tokens from localStorage
132+ const jwtToken = localStorage . getItem ( 'jwt_token' ) ;
132133 const apiKey = localStorage . getItem ( 'api_key' ) ;
133134
134135 const headers = {
135136 'Accept' : 'application/json' ,
136137 } ;
137138
138- // Add Authorization header if API key exists
139- if ( apiKey ) {
139+ // Add Authorization header with JWT token if available, otherwise use API key
140+ if ( jwtToken ) {
141+ headers [ 'Authorization' ] = `Bearer ${ jwtToken } ` ;
142+ } else if ( apiKey ) {
140143 headers [ 'Authorization' ] = `Bearer ${ apiKey } ` ;
141144 }
142145
@@ -205,15 +208,18 @@ export class ApiClient {
205208 * @private
206209 */
207210 static async fetchBinaryResponse ( url , body ) {
208- // Get API key from localStorage
211+ // Get authentication tokens from localStorage
212+ const jwtToken = localStorage . getItem ( 'jwt_token' ) ;
209213 const apiKey = localStorage . getItem ( 'api_key' ) ;
210214
211215 const headers = {
212216 'Content-Type' : 'application/json' ,
213217 } ;
214218
215- // Add Authorization header if API key exists
216- if ( apiKey ) {
219+ // Add Authorization header with JWT token if available, otherwise use API key
220+ if ( jwtToken ) {
221+ headers [ 'Authorization' ] = `Bearer ${ jwtToken } ` ;
222+ } else if ( apiKey ) {
217223 headers [ 'Authorization' ] = `Bearer ${ apiKey } ` ;
218224 }
219225
@@ -239,15 +245,18 @@ export class ApiClient {
239245 * @private
240246 */
241247 static async fetchJsonResponse ( url , body ) {
242- // Get API key from localStorage
248+ // Get authentication tokens from localStorage
249+ const jwtToken = localStorage . getItem ( 'jwt_token' ) ;
243250 const apiKey = localStorage . getItem ( 'api_key' ) ;
244251
245252 const headers = {
246253 'Content-Type' : 'application/json' ,
247254 } ;
248255
249- // Add Authorization header if API key exists
250- if ( apiKey ) {
256+ // Add Authorization header with JWT token if available, otherwise use API key
257+ if ( jwtToken ) {
258+ headers [ 'Authorization' ] = `Bearer ${ jwtToken } ` ;
259+ } else if ( apiKey ) {
251260 headers [ 'Authorization' ] = `Bearer ${ apiKey } ` ;
252261 }
253262
@@ -296,9 +305,14 @@ export class ApiClient {
296305 'Accept' : 'application/json' ,
297306 } ;
298307
299- // Add Authorization header if API key exists
308+ // Get authentication tokens from localStorage
309+ const jwtToken = localStorage . getItem ( 'jwt_token' ) ;
300310 const apiKey = localStorage . getItem ( 'api_key' ) ;
301- if ( apiKey ) {
311+
312+ // Add Authorization header with JWT token if available, otherwise use API key
313+ if ( jwtToken ) {
314+ headers [ 'Authorization' ] = `Bearer ${ jwtToken } ` ;
315+ } else if ( apiKey ) {
302316 headers [ 'Authorization' ] = `Bearer ${ apiKey } ` ;
303317 }
304318
@@ -328,9 +342,14 @@ export class ApiClient {
328342 'Accept' : 'application/json' ,
329343 } ;
330344
331- // Add Authorization header if API key exists
345+ // Get authentication tokens from localStorage
346+ const jwtToken = localStorage . getItem ( 'jwt_token' ) ;
332347 const apiKey = localStorage . getItem ( 'api_key' ) ;
333- if ( apiKey ) {
348+
349+ // Add Authorization header with JWT token if available, otherwise use API key
350+ if ( jwtToken ) {
351+ headers [ 'Authorization' ] = `Bearer ${ jwtToken } ` ;
352+ } else if ( apiKey ) {
334353 headers [ 'Authorization' ] = `Bearer ${ apiKey } ` ;
335354 }
336355
@@ -362,9 +381,14 @@ export class ApiClient {
362381 'Accept' : 'application/json' ,
363382 } ;
364383
365- // Add Authorization header if API key exists
384+ // Get authentication tokens from localStorage
385+ const jwtToken = localStorage . getItem ( 'jwt_token' ) ;
366386 const apiKey = localStorage . getItem ( 'api_key' ) ;
367- if ( apiKey ) {
387+
388+ // Add Authorization header with JWT token if available, otherwise use API key
389+ if ( jwtToken ) {
390+ headers [ 'Authorization' ] = `Bearer ${ jwtToken } ` ;
391+ } else if ( apiKey ) {
368392 headers [ 'Authorization' ] = `Bearer ${ apiKey } ` ;
369393 }
370394
@@ -394,9 +418,14 @@ export class ApiClient {
394418 'Accept' : 'application/json' ,
395419 } ;
396420
397- // Add Authorization header if API key exists
421+ // Get authentication tokens from localStorage
422+ const jwtToken = localStorage . getItem ( 'jwt_token' ) ;
398423 const apiKey = localStorage . getItem ( 'api_key' ) ;
399- if ( apiKey ) {
424+
425+ // Add Authorization header with JWT token if available, otherwise use API key
426+ if ( jwtToken ) {
427+ headers [ 'Authorization' ] = `Bearer ${ jwtToken } ` ;
428+ } else if ( apiKey ) {
400429 headers [ 'Authorization' ] = `Bearer ${ apiKey } ` ;
401430 }
402431
0 commit comments