Mail Application Development Platform API Reference

openmail.AuthService

Methods to interact with authorized web services.

Properties

ERR_AUTH - static int
Deprecated: Use openmail.Errors.ERR_AUTH

Methods

callWebService
int callWebService ( service , handler )
Call a 3rd-party Web service using an authorized (i.e. signed) call. This is similar to openmail.Application.callWebService, but will add any authorization information needed to make the call.

Sample Use:
For usage examples, refer to the YQL Sample App.
Parameters:
service < Object > It may include the following:
url: String Target URL
method: String "GET" or "POST"
parameters: Object A map of key/value pairs to use as the query string or the POST body.
headers: Array of strings An array of HTTP headers as strings. You can set any arbitrary headers if it is accepted by cross-domain policy file. Content-Type header is always accepted. It is only supported for "POST"
body: String Use when POSTing stringified JSON data with ['content-type:application/json'] header, or when POSTing data with ['content-type:multipart/form-data'] header
dataformat: String "text"(default) or "binary". "binary" returns Base64-encoded binary data.
handler < function > A callback function. Callback response Object contains the following data:
On success: response.data contains the HTTP body returned by the Web service.
On failure: response.error contains an error message describing the failure.
Returns: int
An error code.

getAuthService
private AuthService getAuthService ( )
This is tricky because getAuthService is executed locally in app iframe so the wrapper executes getAuthService first then wraps the methods of the returned object
Returns: AuthService

getParameters
int getParameters ( handler )
Use this API to get access to the Logged-In user's protected information. Applications need to be authorized by Yahoo! Mail Application Platform administrator for using this API. Currently Logged-In user's email address and name are exposed.
Parameters:
handler < function > A callback function. Callback response Object has an object response.user This object has following members:
email: Logged-In user's email address.
name: Logged-In user's name same as the name which appears in Compose mail.
Returns: int
An error code.

getStatus
Object getStatus ( handler )
Retrieves current authorization status of the user with respect to the Web service.

Sample Use:
For usage examples, refer to the YQL Sample App.
Parameters:
handler < function > A callback function.

Returns: Object
An object containing information about the authorization status. It has following members:
status: One of following: 'ok', 'failed', or 'authorization required'.
info: If status is 'ok', depending on the profile type, data holds some additional information.

getUserAuthorizationURL
Object getUserAuthorizationURL ( params , handler )
Retrieves the redirection URL that is needed by the user to continue authorization process.

Sample Use:
For usage examples, refer to the YQL Sample App.
Parameters:
params < Object > An object containing the configuration of the auth service requested. Object has following members:
request: Properties of the request object will be added the call for request token.
authorization: Properties of the request object will be added to authorization URL.
handler < function > A callback function.

Returns: Object
An object containing the authorization URL within the following member:
url: The authorization URL.

notifyAuthorizationReceived
Object notifyAuthorizationReceived ( handler )
Tells the authorization service that the user has completed the authorization process. This will initiate the retrieval of the authorization token from the 3rd-party service.

Sample Use:
For usage examples, refer to the YQL Sample App.
Parameters:
handler < function > A callback function.

Returns: Object
Object contains the status of the token retrieval with the following members:
info: Additional information, returned by the service.

removeAuthorization
Object removeAuthorization ( handler )
Removes all authorization tokens and reverts back to initial state.

Sample Use:
For usage examples, refer to the YQL Sample App.
Parameters:
handler < function > A callback function.
Returns: Object
An empty object.