I have an Azure Worker role running a ASP.Net Web API application. This is protected by ACS. When I browse to the web api using a browser, I get challenged by ACS to authenticate against either Google or LiveId. When I authenticate, I can see the data.
I am trying to access the same API from a Win 8 Metro Style App. I am trying to use the WebAuthenticationBroker.
WebAuthenticationResult webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None,
new Uri("https://xxxxx.accesscontrol.windows.net:443/v2/wsfederation?wa=wsignin1.0&wtrealm=http%3a%2f%2fyyyyy.cloudapp.net%2f"),
new Uri("http://yyyyy.cloudapp.net/")
);
When I start the app, it challenges me to Authenticate either through Google or LiveId as before. This passes and I get a successful result.
Then I create a call to the API using a HttpClient:
HttpClient client = new HttpClient();
Uri _baseUri = new Uri("http://yyyyy.cloudapp.net/api/");
client.BaseAddress = _baseUri;
var response = client.GetAsync("Values/").Result;
var responseBodyAsText = response.Content.ReadAsStringAsync().Result;
var ids = JsonConvert.DeserializeObject<IList<int>>(responseBodyAsText);
This sort of works, it appears to be navigating to the URI correctly, but the payload that come back is HTML asking me to log in rather than the JSON data I am expecting.
I have spent more time on this than is sensible and have run out of ideas! Can anyone please help?