using System.Net.Http; using FastEndpoints; using FrameworkBLL.KeyCloak; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.KeyCloak { public class GetMasterAccessToken : BaseEndpoint> { private readonly IKeyCloakBLL _keyCloakBLL; public GetMasterAccessToken(IKeyCloakBLL keyCloakBLL) { _keyCloakBLL = keyCloakBLL; } public override void Configure() { Get("/Keycloak/GetMasterAccessToken"); AllowAnonymous(); } protected override async Task> ExecuteAsync(EmptyRequest req, LoginDTO loginDTO, CancellationToken CancellationToken) { try { string Token = await _keyCloakBLL.GetMasterAccessToken(); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Token, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }