Skip to content


Subversion checkout URL

You can clone with
Download ZIP
StackMob AS3 oauth2 API Connector
Branch: master
Pull request Compare This branch is 10 commits behind cycle-it:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


StackMob AS3 oauth2 API Connector is an actionscript3 library that allows to consume StackMob REST services in compliance with OAuth2 protocol specification.

It is based on Logging in with OAuth 2.0 documentation provided by StackMob team.

Source code

It's a Flex Library Project which the following structure:

  • main: Source code of the library
  • example: Source code of a Flex Mobile Project. You should import it into a new Flex Mobile Project.
  • libs: see dependencies below


It depends on the following libraries (which are included in the project):

  • as3corelib: for the HMAC SHA-1 hash generation of the Authoritation header.
  • base64: for Base64 encoding the previous generated hash.


A functional example could be found under the example directory.

Step by step

First, modify the following constants:

// Your public key
public const XStackMobAPIKey:String = "";
// Username. ie Bruce Wayne
public const username:String = "";
// Password. ie iambatman
public const password:String = "";

Lets consider that we've created a blogentry schema in our StackMob development platform with the following structure:

  • id: blogentry ID
  • message: blogentry message

Now, we want populate this schema with data, consult it later, update some entries and delete the obsolete ones. So:

Create an StackMobService, using your public key (development or production):

var smService:StackMobService = new StackMobService(XStackMobAPIKey, StackMobService.DEVELOPMENT_VERSION);

Lets login with previous username and password:

// login event fired after successful login
smService.addEventListener(LoginEvent.LOGIN, loginHandler);
// loginError event fired in case of error
smService.addEventListener(LoginEvent.LOGIN_ERROR, loginErrorHandler);
smService.login(username, password);

After login you could check your user credentials for further use:

var credentials:Object = smService.credentials;

Now, you can request StackMob API. Every request fires an Event.COMPLETE in case of a HTTP OK response or an Event.IOErrorEvent in other case. In every case, you can check your attribute in order to see the result or the error.

GET all entries


GET one entry

smService.get("blogentry/" +;

POST an entry

var entry:Object = {"message" : "A message"}"blogentry", entry);

PUT an entry

var updatedEntry:Object = {"message" : "Updated message"}
smService.put("blogentry/" +, updatedEntry);

DEL an entry

var entry:Object = {"id" : id}
smService.del("blogentry", entry);
Something went wrong with that request. Please try again.