public async Task <object> GenerateJwt(MvPersonResult personResult) { MvPerson person = new MvPerson(); foreach (var personObj in personResult.person) { person = personObj; } return(await GenerateJwt(GenerateClaimsIdentity(person), person.Username, personResult)); }
public async Task Post(string url, object obj) { var rq = GetApiRequest(Method.POST, url); //get token from session personResult = JsonConvert.DeserializeObject <MvPersonResult>(_httpContextAccessor.HttpContext.Session.GetString("personResult") ?? string.Empty); if (personResult != null && !String.IsNullOrEmpty(personResult.accessToken)) { rq.AddHeader("Authorization", "Bearer " + personResult.accessToken); //rq.AddParameter("Authorization", string.Format("Bearer {0}", accessToken), ParameterType.HttpHeader); } rq.AddJsonBody(obj); await GetApiResponseObject(url, rq); }
public async Task <T> Get <T>(string url) { var rq = GetApiRequest(Method.GET, url); personResult = JsonConvert.DeserializeObject <MvPersonResult>(_httpContextAccessor.HttpContext.Session.GetString("personResult") ?? string.Empty); if (personResult != null && !String.IsNullOrEmpty(personResult.accessToken)) { rq.AddHeader("Authorization", "Bearer " + personResult.accessToken); //rq.AddParameter("Authorization", string.Format("Bearer {0}", accessToken), ParameterType.HttpHeader); } var res = await GetApiResponseObject <T>(url, rq); return(res); }
public EventController(IWebService webService, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) { _webService = webService; _configuration = configuration; personResult = JsonConvert.DeserializeObject <MvPersonResult>(httpContextAccessor.HttpContext.Session.GetString("personResult") ?? string.Empty); }
public async Task <object> GenerateJwt(ClaimsIdentity identity, string username, MvPersonResult personResult) { personResult.accessToken = await GenerateEncodedToken(username, identity); return(personResult); }