Adobe AIR, taking the Browser out of Browser-Based Auth

After my last post about Adobe, everyone probably thinks I hate Adobe. That’s not true at all, I simply had a less than favorable experience porting my application from Adobe AIR Beta 1 to Beta 2.

Just to show that there are no hard feelings, I spent a few hours tonight distilling the authentication bits from Air Mail into something that stands alone. Air Mail uses the Yahoo! Mail Web Service to speak to the Yahoo! Mail backend. As a result, it uses Yahoo! Browser-Based Authentication (BBAuth) to handle user identification. BBAuth, as the name implies, was built to be used within the confines of a browser. That doesn’t mean you can’t build desktop applications, however. You simply need to get the user to use a browser long enough to sign in to Yahoo!.

There are a few ways of doing this, but I think I’ve settled on the one that I like the best. Using flash.net.navigateToURL(), your Adobe AIR application can spawn a browser window using whatever the user selected as the default browser. This allows you to direct the user to the appropriate Yahoo! login page (I send the user to a page on my server that redirects them to the properly formed BBAuth sign-in URL).

Once the user is done logging in, the fun begins. They’re directed back to your web site with an authentication token in the query string. With that token, you can send a request to the BBAuth servers to fetch user credentials. Those credentials can be used to make authenticated web services requests. The problem is, you want to make web services requests directly from the AIR application, not proxied through your web server. Somehow you need to transfer the credentials from the browser to the running AIR application.

Fortunately, there is a solution…flash.net.LocalConnection. The LocalConnection class allows any running Flash movie to talk to another running Flash movie. This includes Flash movies running in the browser and Flash movies running in Adobe AIR. Simply set up a LocalConnection between the two and pass the BBAuth credentials via a method call.

I’ve glossed over this pretty quickly. If you want to know more, I’ve built a sample application that demonstrates BBAuth in Adobe AIR. You can install the sample Adobe AIR application and then go through the process of authentication. If you’re still hungry for more, download the Creative Commons licensed source code in tgz or zip format and play with it yourself.

Next time I’ll show you how to call the Yahoo! Mail Web Service from Adobe AIR now that you have credentials.

4 Responses to “Adobe AIR, taking the Browser out of Browser-Based Auth”

  1. GuillaumeB Says:

    I’ve seen you small interview about Adobe Air at Yahoo Hacks, fabulous!

  2. GuillaumeB Says:

    Hey Ryan

    I have down laoded Adobe Air and your application but it seems that it won’t work with Beta 2. Did you successfully make it work? I’m dying to try it out.

  3. Ryan Says:

    Yes and no. I can run it in the debug runner but I haven’t gotten it to run standalone yet.

  4. GuillaumeB Says:

    ok do let us know when you are done. I really want to test it out. Meanwhile I’ll try to install beta 1 of Air and you first alpha build

Leave a Reply