Charming Web Authentication

Silverlight 8.0

A WebAuthenticationBroker for Silverlight 8.0 projects. Runs in-process unlike the Windows Phone 8.1 version.

Uri callbackUri = new Uri("http://myresponse/");
Uri requestUri = new Uri(string.Format("https://www.yammer.com/dialog/oauth?client_id={0}&redirect_uri={1}&response_type=token", clientId, Uri.EscapeDataString(callbackUri.OriginalString)));

WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, requestUri, callbackUri);

if (result.ResponseStatus == InTheHand.Security.Authentication.Web.WebAuthenticationStatus.Success)
{
   if (result.ResponseData.Contains("access_token"))
   {
      int i = result.ResponseData.IndexOf("access_token=") + 13;

      string yammerKey = result.ResponseData.Substring(i);
   }
   else
   {
      MessageBox.Show("WebAuthenticationBroker Access Token Failed");
   }
}
else
{
   MessageBox.Show("WebAuthenticationBroker Error Response");
}

Last edited May 22, 2014 at 3:50 PM by PeterFoot, version 2