From fe27a2a87d28dcf032030b6d14e235e30ff1123a Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 18 May 2023 14:18:52 +0200 Subject: [PATCH] Generate Hofer access token --- analysis.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/analysis.js b/analysis.js index fd728b0..c15425f 100644 --- a/analysis.js +++ b/analysis.js @@ -71,11 +71,10 @@ async function fetchHofer() { const CONFIG={headers: {authorization: null}} const ITEMS = BASE_URL+`/productlist/CategoryProductList` - // TODO: create/fetch token on the fly - if(CONFIG.headers.authorization == null) { - console.warn("SKIP Hofer (no token set)") - return []; - } + // fetch access token + const token_data ={"OwnWebshopProviderCode":"","SetUserSelectedShopsOnFirstSiteLoad":true,"RedirectToDashboardNeeded":false,"ShopsSelectedForRoot":"hofer","BrandProviderSelectedForRoot":null,"UserSelectedShops":[]} + const token = (await axios.post("https://shopservice.roksh.at/session/configure", token_data, {headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }})).headers['jwt-auth']; + CONFIG.headers.authorization = "Bearer " + token; // concat all subcategories (categories.[i].ChildList) const categories = (await axios.post(CATEGORIES, {}, CONFIG)).data;