I have an Azure webrole that requires ACSv2 authentication that I want to access from a winforms application. Many of my clients use Windows XP so I can not use the WIF (which is not available on Windows XP). What is the best way to get an authentication token for my web request in this case?
For desktop applications you can do the following:
This is similar to when you want to use ACS in a Windows Phone application. I suggest you take a look at this blog post: Azure ACS on Windows Phone 7. And here is the sample code which parses the token after the user logs in through the WebBrowser control (on WP7):
private void SignInWebBrowserControl_ScriptNotify(object sender, NotifyEventArgs e)
{
var acsResponse = ACSResponse.FromJSON(e.Value);
RequestSecurityTokenResponse rstr = null;
Exception exception = null;
try
{
string binaryToken = HttpUtility.HtmlDecode(acsResponse.securityToken);
string tokenText = RequestSecurityTokenResponseDeserializer.ProcessBinaryToken(binaryToken);
DateTime expiration = DateTime.Now + TimeSpan.FromSeconds(acsResponse.expires – acsResponse.created);
rstr = new RequestSecurityTokenResponse
{
Expiration = expiration,
TokenString = tokenText,
TokenType = acsResponse.tokenType
};