Exemple #1
0
 private static void ApplyAuthentication(HttpClient c, ApiInput input)
 {
     if (input.Token != null)
     {
         c.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", input.Token);
     }
 }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
        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));
            }
        }