Mike Chambers

code = joy

Flex based Flickr API Authorization control

with 5 comments

I just checked in some updates to the ActionScript 3 Flickr library. The biggest change is that I checked in a Flex control that will provide a UI and handle all of the communication to authorize an application with Flickr.

There is no documentation on it, and as I have built it for projects I am using, there are probably some API gaps, but it seems to be pretty solid.

Flickr API Auth Flex Component

Here is a simple example of how to use it:

import com.adobe.webapis.flickr.authorization.events.AuthorizationEvent;
import com.adobe.webapis.flickr.authorization.AuthorizationView;
import mx.core.IFlexDisplayObject;
import mx.managers.PopUpManager;

//open the authorization panel
private function openAuthorization():void
{
	var p:IFlexDisplayObject = PopUpManager.createPopUp(this, AuthorizationView, true);

	var auth:AuthorizationView = AuthorizationView(p);

	//get this from flickr
	auth.flickrAPIKey = "XXXXXXXXXXXXXXXXXXXXX";

	//get from flickr
	auth.flickrAPISecret = "XXXXXXXXXXXXXXXXXXXX";
	auth.isPopUp = false;

	p.addEventListener(Event.CLOSE, onAuthorizationClose);
	p.addEventListener(AuthorizationEvent.AUTHORIZATION_COMPLETE, onAuthorizationComplete);

	PopUpManager.centerPopUp(p);
}

private function onAuthorizationClose(e:Event):void
{
	PopUpManager.removePopUp(IFlexDisplayObject(e.target));
}

private function onAuthorizationComplete(e:AuthorizationEvent):void
{
	trace(e.authToken);
	trace(e.user.username);
}

Basically, this will open a panel that walks the user through the authorization steps (which requires a visit to the Flickr site in the user’s browser). Once the authorization is complete, an event is thrown with the authorization token (which should then be saved between app sessions).

Flickr API Auth Flex Component

The api requires that your app have an api key and secret key, both of which you can grab from flickr at:
http://www.flickr.com/services/api/keys/apply/

Flickr API Auth Flex Component

If you run into any issues, or have any suggestions either log a bug on the flickr lib project site, or post a comment here. Plus, if anyone thinks that can make the UI look prettier, just ping me.

Written by mikechambers

August 12th, 2008 at 2:14 pm

Posted in General

5 Responses to 'Flex based Flickr API Authorization control'

Subscribe to comments with RSS or TrackBack to 'Flex based Flickr API Authorization control'.

  1. Thanks a lot for this Mike.

    eric dolecki

    12 Aug 08 at 6:24 pm

  2. Hi there,
    What i’d like to do is have AS3 access one of my own private photoSets, but I don’t want every user/visitor to my site to have to log in to flickr. Is this (having the user authenticate via a flickr URL) the *only* way to get an auth_token? Or is that unnecessary as I’m accessing my own photoSet?
    Thanks in advance!

    steve

    9 Sep 08 at 5:47 pm

  3. Was starting coding exactly that on top of as3flickr when I encountered your post. You saved me some precious time. Next time I’ll update my SVN before coding ;) I hope to come up with an example showing the usage of the AS3 flickr with ILOG Elixir for MAX.

    Christophe

    10 Oct 08 at 6:19 am

  4. Well, actually, I updated SVN but the new classes are not compiling :-( Did I miss something?

    Christophe

    10 Oct 08 at 6:34 am

  5. Ok, got it, bad Flex Builder configuration. Sorry for my previous comment, you can ignore it ;)

    Christophe

    10 Oct 08 at 6:36 am

Leave a Reply