Can I use .NET's HttpClient to hit an Azure Mobile service?
How do I authenticate with the Mobile Service's own baked in custom Authentication/Authorization patterns with the HttpClient?
This always returns 401, because I'm not passing in any authentication credentials:
var client = new HttpClient();
var response = client.GetAsync("http://localhost:49190/api/test").Result;
Furthermore, how come when I use the Mobile Service Client, why does my application key, master key, or user auth key always return (401) Unauthorized?
Client:
var mobileClient = new MobileServiceClient("http://localhost:49190/", "[my key]");
var response = mobileClient.InvokeApiAsync("test").Result;
Service Side:
[AuthorizeLevel(AuthorizationLevel.Application)]
public class TestController : ApiController
{
public ApiServices Services { get; set; }
// GET api/Test
public string Get()
{
Services.Log.Info("Hello from custom controller!");
return "Hello";
}
}