private static void ApplyAuthentication(HttpClient c, ApiInput input) { if (input.Token != null) { c.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", input.Token); } }
public async Task <IActionResult> RegisterLocalHue([FromBody] ApiInput input) { using (HttpClient c = new HttpClient()) { // {"devicetype":"my_hue_app#iphone peter"} var response = await c.PostAsync(input.BaseUrl, new JsonContent(new { devicetype = "KronisHueWeb" })); return(await Forward(response)); } }
public async Task <IActionResult> GetGroups([FromBody] ApiInput input) { using (HttpClient c = new HttpClient()) { ApplyAuthentication(c, input); var response = await c.GetAsync($"{input.ApiUrl}/groups"); return(await Forward(response)); } }