From 1f8987d1d05b6aae64bf8485f33e44165b871493 Mon Sep 17 00:00:00 2001 From: Giulio <3272563+giuliohome@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:42:32 +0200 Subject: [PATCH] access token --- src/web/src/services/restService.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/web/src/services/restService.ts b/src/web/src/services/restService.ts index a12f1e6e..0104c279 100644 --- a/src/web/src/services/restService.ts +++ b/src/web/src/services/restService.ts @@ -1,4 +1,5 @@ import axios, { AxiosInstance } from 'axios'; +import { useAuth0, withAuthenticationRequired } from "@auth0/auth0-react"; export interface QueryOptions { top?: number; @@ -21,9 +22,19 @@ export abstract class RestService { } public async getList(queryOptions?: QueryOptions): Promise { + const { + getAccessTokenSilently, + loginWithPopup, + getAccessTokenWithPopup, + } = useAuth0(); + const token = await getAccessTokenSilently(); const response = await this.client.request({ method: 'GET', - data: queryOptions + data: queryOptions, + headers: { + Authorization: `Bearer ${token}`, + } + }); return response.data;