Vittorio wrote a post earlier today showing how to fetch the identity provider feed from ACS and use it to drive the sign-in handshake from within your application and UI.
This is indeed a very useful (and user friendly) approach. Call me old fashioned, but I’d rather like to do that using C#/server side ;)
I wrote a simple class that turns the ACS identity provider feed into an object model. In essence the logic looks like this:
public async Task<List<IdentityProviderInformation>> GetAsync(
string protocol)
{
var url = string.Format(
“https://{0}.{1}/v2/metadata/IdentityProviders.js?protocol={2}&realm={3}&context={4}&version=1.0”,
AcsNamespace,
“accesscontrol.windows.net”,
protocol,
Realm,
Context);
var jsonFormatter = new JsonMediaTypeFormatter();
jsonFormatter.SupportedMediaTypes.Add(
new MediaTypeHeaderValue(“text/javascript”));
var formatters = new List<MediaTypeFormatter>()
{
jsonFormatter
};
var client = new HttpClient();
var response = await client.GetAsync(new Uri(url));
return await
response.Content.ReadAsAsync<List<IdentityProviderInformation>>(
formatters);
}
From there you can data bind to a UI control (e.g. WPF, WP, WebForms) or pass on to a MVC view (honoring the MVC model ;)).
Here’s the full source code, and here a WPF client sample.
HTH
Filed under: Azure, IdentityModel
