Packagecom.myflashlab.air.extensions.fb
Classpublic class Auth
InheritanceAuth Inheritance flash.events.EventDispatcher

Loging your users to your app is the most important task you may need when working with a facebook extension in your app This class will provide you everything you would need about logging in and out with letting you know about the permissions that the user has given to you and also this class will provide you with the token id of the current active session in your app. (you may use the token for complex graph API calls.)

What I like to emphasize here is that you should forget the word "login" when working with facebook SDK! because you are actually requesting for permissions from your users. if they grand you with the permissions you are asking, then they can use your app features.

The beauty of this system is that you can easily manage what features your users can have access to based on the permissions they have granted.

The best practice is to ask for more permissions in your app ONLY when you need them. do NOT scare your users off too quickly! :)



Public Properties
 PropertyDefined By
  currentAccessToken : AccessToken
The access token that is current for the application.
Auth
  defaultAudience : int
Indicates the default audience.
Auth
  loginBehavior : int
Indicates the login behavior.
Auth
Public Methods
 MethodDefined By
  
getCurrentProfile($callback:Function):void
Returns basic profile information of the logged in user.
Auth
  
Auth
  
login($isPublishPermissions:Boolean, $permissions:Array, $callback:Function):void
Use this method to login your users to your app based on the list of permissions you need.
Auth
  
logout():void
Logs out the user.
Auth
  
manualInit($accessToken:String, $applicationId:String, $userId:String, $permissions:Array = null, $declinedPermissions:Array = null, $expirationTime:Number, $lastRefreshTime:Number):AccessToken
Creates a new AccessToken using the supplied information from a previously-obtained access token (for instance, from an already-cached access token obtained prior to integration with the Facebook SDK).
Auth
  
refreshCurrentAccessToken($callback:Function):void
Updates the current access token and extends the expiration date, if extension is possible.
Auth
Property Detail
currentAccessTokenproperty
currentAccessToken:AccessToken

The access token that is current for the application.


Implementation
    public function get currentAccessToken():AccessToken
    public function set currentAccessToken(value:AccessToken):void
defaultAudienceproperty 
defaultAudience:int

Indicates the default audience. you should set this if you intend to ask for publish permissions.


Implementation
    public function get defaultAudience():int
    public function set defaultAudience(value:int):void
loginBehaviorproperty 
loginBehavior:int

Indicates the login behavior.


Implementation
    public function get loginBehavior():int
    public function set loginBehavior(value:int):void
Method Detail
getCurrentProfile()method
public function getCurrentProfile($callback:Function):void

Returns basic profile information of the logged in user. on first login attempt, it may return null in the callback function. It is recommended to use graph API for obtaining user information.

Parameters

$callback:Function — callback function to be called with the result of this operation. This function expects 1 parameter.
  • $profile:Profile
  • which might be null at the first login attempt

isCurrentAccessTokenActive()method 
public function isCurrentAccessTokenActive():Boolean

Returns
Boolean
login()method 
public function login($isPublishPermissions:Boolean, $permissions:Array, $callback:Function):void

Use this method to login your users to your app based on the list of permissions you need.

Parameters

$isPublishPermissions:Boolean — set to true if you are asking for publish permissions. if not, you should pass false.
 
$permissions:Array — List of permissions you want to ask based on Permissions class.
 
$callback:Function — callback function to be called with the result of login operation. this function expects 5 parameters.
  • $isCanceled:Boolean - indicates if the login process has been canceled by user or not.
  • $error:Error - If not null, it means that login process has been terminated by an error.
  • $accessToken:AccessToken - If no error and not canceled, this will be available.
  • $recentlyDeclined:Array - If $accessToken is available.
  • $recentlyGranted:Array - If $accessToken is available.

logout()method 
public function logout():void

Logs out the user.

manualInit()method 
public function manualInit($accessToken:String, $applicationId:String, $userId:String, $permissions:Array = null, $declinedPermissions:Array = null, $expirationTime:Number, $lastRefreshTime:Number):AccessToken

Creates a new AccessToken using the supplied information from a previously-obtained access token (for instance, from an already-cached access token obtained prior to integration with the Facebook SDK). Note that the caller is asserting that all parameters provided are correct with respect to the access token string; no validation is done to verify they are correct.

IMPORTANT: This initializer should only be used for advanced apps that manage tokens explicitly.

Parameters

$accessToken:String — the access token string obtained from Facebook
 
$applicationId:String — the ID of the Facebook Application associated with this access token
 
$userId:String — the id of the user
 
$permissions:Array (default = null) — the permissions that were requested when the token was obtained (or when it was last reauthorized); may be null if permission set is unknown
 
$declinedPermissions:Array (default = null) — the permissions that were declined when the token was obtained; may be null if permission set is unknown
 
$expirationTime:Number (default = NaN) — the expiration date associated with the token; if NaN, an infinite expiration time is assumed (but will become correct when the token is refreshed)
 
$lastRefreshTime:Number (default = NaN) — the last time the token was refreshed (or when it was first obtained); if NaN, the current time is used.

Returns
AccessToken
refreshCurrentAccessToken()method 
public function refreshCurrentAccessToken($callback:Function):void

Updates the current access token and extends the expiration date, if extension is possible.

Parameters

$callback:Function — callback function to be called with the result of this operation. This function expects 2 parameters.
  • $accessToken:AccessToken - If no error, this will be available.
  • $error:Error - If not null, it means the process has been terminated by an error.