Fixing the Security Sandbox errors with AS3 Flickr API

One of the recent experiments I tried was with the AS3 Flickr API. Adobe Labs has published a library called as3flickrlib on Google Code which makes it easier to access your flickr photos. So I downloaded that (using the flickr-.85.zip link under the Featured Downloads section) and started playing with it. I felt it was pretty straightforward to use it, partly because I have used other Flickr libraries like Flickr.Net for the .Net framework.

When developing inside Flex Builder my code worked great and I could access images and other information through the library. But when I deployed the compiled version to my server, I started getting Error#2048: Security Sandbox violation. Cannot load resource from http://flickr.com/… I knew that this error had to do something with the crossdomain.xml policy file that must deployed on Flickr so that external access to it is allowed. When I did a Google search on “crossdomain flickr”, I did find the policy file on http://api.flickr.com/crossdomain.xml. But surprisingly the domain was api.flickr.com and not flickr.com, as it stated in my security error.

After a couple more Google searches I came upon this YahooGroups post where it said that the API end-point for Flickr has changed! AHA! This made me think that the as3flickrlib must be still using the old flickr.com endpoint. Sure enough, when I opened up the source for FlickrService.as, it was using the wrong end-point.

public class FlickrService extends URLLoaderBase { /** * The REST endpoint where we can talk with Flickr service */ public static const END_POINT:String = "http://flickr.com/services/rest/?";

To fix that, I looked at the sources for as3flickrlib on the Google Code Subversion repository. Interestingly FlickrService.as over there was using the correct end-point (api.flickr.com). So I got hold of the sources for as3flickrlib and the dependency: as3corelib, recompiled them inside Flex Builder and generated a new as3flickrlib.swc. Using that, things started working like expected.

So if any of you are using the SWC from the zip file provided on as3flickrlib Google Code project, it is NOT going to work when you deploy your application online. You can use my recompiled SWC, which I have uploaded over here. Ideally Adobe should be updating the build and uploading the new version. Right now the source in SVN and the compiled zip are not in sync :-(.

 

 

Technorati tags: , , , ,
Advertisements

Nagging username/password dialogs with SubClipse

I started working on a little pet project for browsing flickr images via a Flex application and using the Cairngorm architecture. I was reading about Cairngorm since the last few days and thought I should make a Flickr app using that architecture. To make it easier for me to get version control I created a Google-Code project called onclick. If you look at the description of the project on the site you would notice that I mention WPF/XAML as my primary technologies. You can disregard that for the time being since all the flex code has been checked under the /flex folder in the subversion repository.

To make it easier for me to access this via Flex Builder, I installed the SubClipse plugin. However, when I specified the repository URL for checkout it kept on asking me for my username/password repeatedly. This happened even after checking the “Save Password” checkbox in that dialog. After a few times it was getting frustrating and I had to do something about it. Fortunately with a quick Google search I found about this thread which discussed the exact same problem. The post hints about getting the command line version of SVN and then executing an update. This will cache the username/password and then SubClipse should not bug anymore. I decided to use the TortoiseSVN client instead to cache the username/password since it would internally invoke the SVN command line.

To do that I went to the Repo Browser and specified my Google-Code URL. It asked me for my username/password and I was able to browse my repository.

Later when I switched back to SubClipse to do a checkout it was smooth as butter. No username/password dialogs whatsoever. Life is good now.