| Package | com.yahoo.social.methodgroups |
| Class | public class AuthorizationRequest |
| Inheritance | AuthorizationRequest YOSMethodBase flash.events.EventDispatcher |
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
| Property | Defined by | ||
|---|---|---|---|
![]() | consumer : OAuthConsumer
An OAuthConsumer object containing consumer key and secret values.
| YOSMethodBase | |
| oAuthLang : String = "en_US"
The OAuth Language Preference.
| AuthorizationRequest | ||
![]() | token : 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 | |
![]() | user : YahooUser
The user referenced in all data requests.
| YOSMethodBase | |
| Method | Defined 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 | ||
| Event | Summary | Defined 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 | |||
![]() | Dispatched when a request fails due to a security error. | YOSMethodBase | ||
| Constant | Defined by | ||
|---|---|---|---|
![]() | APPSTORE_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 | ||
![]() | SOCIAL_WS_HOSTNAME : String = "social.yahooapis.com" [static]
The hostname for Yahoo Social APIs.
| YOSMethodBase | |
![]() | YQL_HOSTNAME : String = "query.yahooapis.com" [static]
The hostname for the YQL API.
| YOSMethodBase | |
| oAuthLang | property |
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.
| AuthorizationRequest | () | constructor |
public function AuthorizationRequest()Creates a new AuthenticationRequest object.
| checkExpires | () | method |
public static function checkExpires(token:OAuthToken, buffer:int = 30):BooleanChecks if a token is about to expire (up to 30 seconds). Returns true if expired.
Parameterstoken: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.
|
Boolean |
| createAuthorizationUrl | () | method |
public function createAuthorizationUrl(requestToken:OAuthToken):StringReturns a URL to be used to send a user to the OAuth authorization page.
ParametersrequestToken:OAuthToken — An OAuthToken object containing a token key and secret.
|
String |
| fromSession | () | method |
public static function fromSession(session:YahooSession):AuthorizationRequestGenerates a new AuthorizationRequest object using the OAuth consumer credentials from a YahooSession instance.
Parameterssession:YahooSession |
AuthorizationRequest |
| getAccessToken | () | method |
public function getAccessToken(token:OAuthToken, verifier:String = null):voidSends a request to fetch an access token.
Parameterstoken: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):voidSends a request to fetch a request token.
ParameterscallbackUrl: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"):voidGenerates an authorization url and navigates the browser to the page.
Parameterstoken: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):OAuthTokenConverts 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.
Parametersdata:Object |
OAuthToken |
| toRequestToken | () | method |
public static function toRequestToken(data:Object):OAuthTokenConverts 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.
Parametersdata:Object |
OAuthToken |
| getAccessTokenFailure | event |
| getAccessTokenSuccess | event |
YahooResultEvent
Dispatched when the getAccessToken request executes successfully.
| getRequestTokenFailure | event |
YahooResultEvent
Dispatched when the getRequestToken request encounters an error.
| getRequestTokenSuccess | event |
YahooResultEvent
Dispatched when the getRequestToken request executes successfully.
| OUT_OF_BAND | constant |
protected static const OUT_OF_BAND:String = "oob"Out-of-band OAuth 1.0 'Rev A' parameter indicating a consumer cannot recieve callbacks.