MAUI-ba is jól bele lett rakva a Bearer token, ha van.

This commit is contained in:
2025-03-14 12:19:16 +01:00
parent 50b14e8122
commit a72c9b342e
9 changed files with 50 additions and 8 deletions
@@ -1,8 +1,11 @@
using AutoMapper;
using DevExpress.XtraPrinting.Native;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using WorkFlowCheck.MAUI.DataLayer;
@@ -31,5 +34,14 @@ namespace WorkFlowCheck.MAUI.Services
var apiKey = configuration["ApiKey"];
_httpClient.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
}
protected async Task PrepareAuthenticatedRequestAsync()
{
var jwtToken = await SecureStorage.GetAsync("AuthToken");
if (!string.IsNullOrEmpty(jwtToken) && _httpClient != null)
{
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwtToken);
}
}
}
}