Generate Hofer access token

This commit is contained in:
Matthias Hochsteger 2023-05-18 14:18:52 +02:00
parent c94472eb25
commit fe27a2a87d

View File

@ -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;