Packagecom.yahoo.social.methodgroups
Classpublic class AuthorizationRequest
InheritanceAuthorizationRequest Inheritance YOSMethodBase Inheritance flash.events.EventDispatcher

A wrapper over the OAuth authorization APIs for Yahoo!. Allows for the full authorization flow to occur inside an application. (Most useful for AIR applications)


Example
   var _session:YahooSession = new YahooSession('consumerKey', 'consumerSecret','appId');
   var _user:YahooUser;
  
   var _token:OAuthToken;
   
   var _callbackUrl = "http://myapp.com/";
   
   _session.auth.addEventListener(YahooResultEvent.GET_REQUEST_TOKEN_SUCCESS, handleRequestTokenSuccess);
   _session.auth.getRequestToken(_callbackUrl);
   
   function handleRequestTokenSuccess(event:YahooResultEvent):void
   {
     // save the request token and use it to send the user to the authorize page
     // then after the user has finished, use it again to request an access token.
  
     _token = event.data as OAuthToken; 
     _session.auth.sendToAuthorization(_token);
   }
  
   // call userAuthFinish after the user has indicated that they have finished the authorization process
  
   function userAuthFinish():void
   {
     // fetch the oauth_verifier. this string may be typed 
     // into your application by the user or returned via the callback url.
     var verifier:String = "abc123";
  
     // reuse the request token to request an access token.
  
     _session.auth.addEventListener(YahooResultEvent.GET_ACCESS_TOKEN_SUCCESS, handleAccessTokenSuccess);
     _session.auth.getAccessToken(_token, verifier);
   }
   
   function handleAccessTokenSuccess(event:YahooResultEvent):void
   {
     // save the access token and create a new session.
     _token = event.data as OAuthToken;
     
     // set the sessions token.
     _session.setAccessToken(_token);
  
     _user = _session.getSessionedUser();
   }
  
  

See also

http://developer.yahoo.com/oauth
http://developer.yahoo.com/oauth/guide/


Public Properties
 PropertyDefined by
 Inheritedconsumer : OAuthConsumer
An OAuthConsumer object containing consumer key and secret values.
YOSMethodBase
  oAuthLang : String = "en_US"
The OAuth Language Preference.
AuthorizationRequest
 Inheritedtoken : OAuthToken
An OAuthToken object containing access token key and secret values This value is only used if a user is not defined when signing a request with OAuth.
YOSMethodBase
 Inheriteduser : YahooUser
The user referenced in all data requests.
YOSMethodBase
Protected Properties
 PropertyDefined by
 Inherited$consumer : OAuthConsumer
An OAuthConsumer object containing consumer key and secret values.
YOSMethodBase
 Inherited$format : String = "json"
The response format to apply to all requests.
YOSMethodBase
 Inherited$hostname : String
The hostname to be used in constructing URLs for all requests.
YOSMethodBase
 Inherited$oauthRequestType : String
The name of the OAuth request type used for all requests in this class.
YOSMethodBase
 Inherited$token : OAuthToken
An OAuthToken object containing access token key and secret values.
YOSMethodBase
 Inherited$useExplicitEncoding : Boolean = true
Determines if the request parameters in the signature base string should be encoded using encodeURIComponent when signing the request.
YOSMethodBase
 Inherited$user : YahooUser
The YahooUser to reference in all requests.
YOSMethodBase
 Inherited$version : String = "v1"
The version of the API.
YOSMethodBase
 InheritedOAUTH_HOSTNAME : String = "api.login.yahoo.com"
[static] The hostname for the Yahoo login service (OAuth) API.
YOSMethodBase
 InheritedOAUTH_REALM : String = "yahooapis.com"
[static] The name of the OAuth realm for Yahoo! web-services.
YOSMethodBase
Public Methods
 MethodDefined by
  
Creates a new AuthenticationRequest object.
AuthorizationRequest
  
checkExpires(token:OAuthToken, buffer:int = 30):Boolean
[static] Checks if a token is about to expire (up to 30 seconds).
AuthorizationRequest
  
createAuthorizationUrl(requestToken:OAuthToken):String
Returns a URL to be used to send a user to the OAuth authorization page.
AuthorizationRequest
  
[static] Generates a new AuthorizationRequest object using the OAuth consumer credentials from a YahooSession instance.
AuthorizationRequest
  
getAccessToken(token:OAuthToken, verifier:String = null):void
Sends a request to fetch an access token.
AuthorizationRequest
  
getRequestToken(callbackUrl:String = null):void
Sends a request to fetch a request token.
AuthorizationRequest
  
sendToAuthorization(token:OAuthToken, window:String = "_blank"):void
Generates an authorization url and navigates the browser to the page.
AuthorizationRequest
  
toAccessToken(data:Object):OAuthToken
[static] Converts a native object containing access token values into a new OAuthToken object.
AuthorizationRequest
  
toRequestToken(data:Object):OAuthToken
[static] Converts a native object containing request token values into a new OAuthToken object.
AuthorizationRequest
Protected Methods
 MethodDefined by
 Inherited
decodeJSON(s:String):*
A simple wrapper of the JSON::decode function.
YOSMethodBase
 Inherited
encodeJSON(o:Object):String
A simple wrapper of the JSON::encode function.
YOSMethodBase
 Inherited
Returns an object containing the required or default request parameters.
YOSMethodBase
 Inherited
getResponseStatusOk(status:int):Boolean
Returns true if the status code is 200.
YOSMethodBase
 Inherited
handleSecurityError(response:Object):void
Dispatches a SECURITY_ERROR event.
YOSMethodBase
 Inherited
sendRequest(httpMethod:String, url:String, callback:Object, args:Object = null, headers:Array = null):void
Signs the request with OAuth credentials then sends the request to the web-service with the supplied callbacks.
YOSMethodBase
Events
 EventSummaryDefined by
   Dispatched when the getAccessToken request encounters an error.AuthorizationRequest
   Dispatched when the getAccessToken request executes successfully.AuthorizationRequest
   Dispatched when the getRequestToken request encounters an error.AuthorizationRequest
   Dispatched when the getRequestToken request executes successfully.AuthorizationRequest
 Inherited Dispatched when a request fails due to a security error.YOSMethodBase
Protected Constants
 ConstantDefined by
 InheritedAPPSTORE_WS_HOSTNAME : String = "appstore.apps.yahooapis.com"
[static] The hostname for the Yahoo Application Platform data store.
YOSMethodBase
  OUT_OF_BAND : String = "oob"
[static] Out-of-band OAuth 1.0 'Rev A' parameter indicating a consumer cannot recieve callbacks.
AuthorizationRequest
 InheritedSOCIAL_WS_HOSTNAME : String = "social.yahooapis.com"
[static] The hostname for Yahoo Social APIs.
YOSMethodBase
 InheritedYQL_HOSTNAME : String = "query.yahooapis.com"
[static] The hostname for the YQL API.
YOSMethodBase
Property detail
oAuthLangproperty
public var oAuthLang:String = "en_US"

The OAuth Language Preference. (xoauth_lang_pref, OAuth 1.0) Set to null if your service provider does not not accept this argument.

Constructor detail
AuthorizationRequest()constructor
public function AuthorizationRequest()

Creates a new AuthenticationRequest object.

Method detail
checkExpires()method
public static function checkExpires(token:OAuthToken, buffer:int = 30):Boolean

Checks if a token is about to expire (up to 30 seconds). Returns true if expired.

Parameters
token:OAuthToken — An OAuthToken containing a token key, secret and a tokenExpires property.
 
buffer:int (default = 30) — The total amount of seconds to pad the expires time with.

Returns
Boolean
createAuthorizationUrl()method 
public function createAuthorizationUrl(requestToken:OAuthToken):String

Returns a URL to be used to send a user to the OAuth authorization page.

Parameters
requestToken:OAuthToken — An OAuthToken object containing a token key and secret.

Returns
String
fromSession()method 
public static function fromSession(session:YahooSession):AuthorizationRequest

Generates a new AuthorizationRequest object using the OAuth consumer credentials from a YahooSession instance.

Parameters
session:YahooSession

Returns
AuthorizationRequest
getAccessToken()method 
public function getAccessToken(token:OAuthToken, verifier:String = null):void

Sends a request to fetch an access token.

Parameters
token:OAuthToken — A request token to be authorized.
 
verifier:String (default = null) — The oauth_verifier returned to the application by the service provider.
getRequestToken()method 
public function getRequestToken(callbackUrl:String = null):void

Sends a request to fetch a request token.

Parameters
callbackUrl:String (default = null) — An optional callback url used after the user has authorized the application.
sendToAuthorization()method 
public function sendToAuthorization(token:OAuthToken, window:String = "_blank"):void

Generates an authorization url and navigates the browser to the page.

Parameters
token:OAuthToken — A request token object.
 
window:String (default = "_blank") — The window of the browser to open the URL in.
toAccessToken()method 
public static function toAccessToken(data:Object):OAuthToken

Converts a native object containing access token values into a new OAuthToken object. Most useful in AIR you are storing the access token in a File and need to turn the Object back into an OAuthToken after reading the file contents.

Parameters
data:Object

Returns
OAuthToken
toRequestToken()method 
public static function toRequestToken(data:Object):OAuthToken

Converts a native object containing request token values into a new OAuthToken object. Most useful in AIR you are storing the request token in a File and need to turn in back into an OAuthToken after reading the file contents.

Parameters
data:Object

Returns
OAuthToken
Event detail
getAccessTokenFailureevent 
Event object type: YahooResultEvent

Dispatched when the getAccessToken request encounters an error.

getAccessTokenSuccessevent  
Event object type: YahooResultEvent

Dispatched when the getAccessToken request executes successfully.

getRequestTokenFailureevent  
Event object type: YahooResultEvent

Dispatched when the getRequestToken request encounters an error.

getRequestTokenSuccessevent  
Event object type: YahooResultEvent

Dispatched when the getRequestToken request executes successfully.

Constant detail
OUT_OF_BANDconstant
protected static const OUT_OF_BAND:String = "oob"

Out-of-band OAuth 1.0 'Rev A' parameter indicating a consumer cannot recieve callbacks.