Flex and TripIt Integration Example with OAuth Authorization

I have been playing with the TripIt API yesterday. TripIt provides typical RESTful services to access your travel data. Like other Web APIs, they use OAuth (Open Authorization) to allow third-party applications to access your protected TripIt data without requiring you to enter your TripIt credentials in the third-party app.

The authorization workflow goes like this:

  1. Get a Request Token. The third-party application invokes a TripIt service that returns a “Request Token”. At this point the token is “unauthorized”.
  2. Authorize the token. The third-party application opens a browser window (navigateToURL) with a specific TripIt page where you can authenticate and grant access to the third-party application (aka authorize the token).
  3. Obtain an Access Token. The third-party application invokes a TripIt service that returns an authorized “Access Token”.
  4. Access protected resources.

The key point is that you never provide your TripIt credentials to the third-party application.

Since it required a little bit of work to implement this in ActionScript, I figured I would share my example. The good news is that I didn’t have to create my own OAuth client implementation in ActionScript. I found the oauth-as3 library on Google Code (Kudos to Shannon Hicks). Even though this is a TripIt example, you should be able to use it as a reference for integrating with other services using OAuth.

The UI Workflow

Here is how I built the UI to support the OAuth authorization steps. After it obtains a Request Token from TripIt, the application displays the following screen:

When you click the “Authorize Token” button, the application opens a browser window with a TripIt page where you can authenticate and grant access to the application.

You then come back to the Flex application and click the “Access Granted” button to let the app know that you are done on the TripIt page. When you click the “Access Granted” button, the application invokes a TripIt service that returns an authorized “Access Token”.

Once the application gets the Access Token, it can start accessing protected resources.

Source Code and AIR Application

You can download the Flex Project here.

You can install the application using the badge below:

[airbadge]AIR Web Server, http://coenraets.org/samples/tripit/TripItDemo.air, 1.0, http://coenraets.org/samples/tripit/logo.gif[/airbadge]

17 Responses to Flex and TripIt Integration Example with OAuth Authorization

  1. Shannon Hicks December 15, 2010 at 10:09 am #

    Well, I’m glad someone wrote an example on how to use my library :)

  2. Christophe Coenraets December 15, 2010 at 10:17 am #

    Great job Shannon! Very easy to use and worked flawlessly.

  3. Surge December 27, 2010 at 12:41 pm #

    This is cool stuff, when I went to follow the link I found it to be broken. I would like to see the source code.

  4. maç oyunları January 11, 2011 at 12:59 am #

    Great, very easy and fast..

  5. kız oyunu February 2, 2011 at 4:52 am #

    Thnaks…Very easy to use and worked flawlessly.

  6. çocuk oyunu February 2, 2011 at 4:58 am #

    Great job Shannon..

  7. savaş oyunları February 2, 2011 at 5:00 am #

    I would like to see the source code.

  8. savaş oyunu March 7, 2011 at 6:25 am #

    Very easy to use and worked flawlessly. Thanks….

  9. ev dekor oyunları March 7, 2011 at 6:26 am #

    Grettings. Good work.. Thanks…

  10. Barbi oyunu March 7, 2011 at 6:27 am #

    Thanks admin. Nice topic..

  11. araba yarış oyunu March 7, 2011 at 6:29 am #

    Thank you very much for professional templates and community edition …

  12. korku oyunu March 7, 2011 at 6:30 am #

    This is cool stuff.. Good work…

  13. maç oyunu oyna March 7, 2011 at 6:32 am #

    I would like to see the source code. Thanks…

  14. flex developer April 15, 2011 at 4:44 am #

    Nice Blog, it is the very helpful to me as well as every flex developer if you help us with source code.

  15. muaz February 13, 2012 at 7:14 pm #

    hello
    Thanks for sharing useful code and example.
    can u help me how to run this example for mobile devices. because i want to create an app for tripit.

    Thanks

  16. ev oyunu January 17, 2013 at 7:29 am #

    Thanks for all of your hard work!

Trackbacks/Pingbacks

  1. SavageLook.com » Shit My Twitter Says #1 - December 17, 2010

    [...] Using OAuth with Adobe Air and Flex [...]

Leave a Reply

css.php