Silverlight 4 authentication for web clients - who else has this job?

So, one of the best parts of the new Silverlight 4 beta is that they finally implemented the big missing network stack - Network Credentials!

In the example below, I have a working request setup, but for some reason I get a "security error" when the request returns - this is because twitter.com rejected my api call or something that I am missing in the code ?

It would be nice to note that when I watch this code run through fiddler, it shows that the xml file for the cross domain is successfully reset, but this is the last request shown by fiddler ...

public void RequestTimelineFromTwitterAPI() { WebRequest.RegisterPrefix("https://", System.Net.Browser.WebRequestCreator.ClientHttp); WebClient myService = new WebClient(); myService.AllowReadStreamBuffering = true; myService.UseDefaultCredentials = false; myService.Credentials = new NetworkCredential("username", "password"); myService.UseDefaultCredentials = false; myService.OpenReadCompleted += new OpenReadCompletedEventHandler(TimelineRequestCompleted); myService.OpenReadAsync(new Uri("https://twitter.com/statuses/friends_timeline.xml")); } public void TimelineRequestCompleted(object sender, System.Net.OpenReadCompletedEventArgs e) { //anytime I query for e.Result I get a security error } 
+4
source share
1 answer

I found 2 issues that caused this request to throw a security exception

1) - In this video from Tim Heuer, it turns out that my installation of VS2010 w / Silverlight 4 did not match the final assembly, so I don’t have the option displayed in the "from browser settings" dialog box, in which the "Require increased trust when working for outside the browser. "

In the video above Tim checks this out, so the Silverlight app can talk to the twitter API

But since my application did not have this option, I had to manually edit the XML file to look like this. You can find this xml by properties in the project folder or inside the visual studio directly.

 <OutOfBrowserSettings ShortName="TrustedNetworkApp Application" EnableGPUAcceleration="False" ShowInstallMenuItem="True"> <OutOfBrowserSettings.Blurb>TrustedNetworkApp Application on your desktop; at home, at work or on the go.</OutOfBrowserSettings.Blurb> <OutOfBrowserSettings.WindowSettings> <WindowSettings Title="TrustedNetworkApp Application" Height="480" Width="640" /> </OutOfBrowserSettings.WindowSettings> <OutOfBrowserSettings.SecuritySettings> <SecuritySettings ElevatedPermissions="Required" /> </OutOfBrowserSettings.SecuritySettings> <OutOfBrowserSettings.Icons /> </OutOfBrowserSettings> 

Pay attention to security settings ** ElevatedPermissions = "Required"

After saving, this is equivalent to checking this, as Tim did in the video.

2) - since I watched this video by Tim, I noticed that you have to debug this outside the browser to make it work. Therefore, install the application and run it outside the browser. This application now works.

I will write a short blog entry to summarize my experience with the network stack under the beta version and a link to it for everyone who is interested.

Update

I finally wrote a blog post about my experience creating a Twitter Twitter client using Silverlight 4, if anyone is interested.

+2
source

All Articles