Class Index | File Index

Classes


Namespace Sfdc.canvas.oauth

Sfdc.canvas.oauth
Defined in: oauth.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
Refreshes the parent window only if the child window is closed.
 
Parses the hash value that is passed in and sets the access_token and instance_url cookies if they exist.
 
Sets, gets or removes the instance_url cookie

This function does one of three things
If the 'i' parameter is not passed in, the current value for the instance_url cookie is returned.

 
Returns the login state
 
login(ctx)
Opens the OAuth popup window to retrieve an OAuth token
 
Returns the url for the OAuth authorization service
 
Removes the access_token oauth token from this object.
 
token(t)
Sets, gets or removes the access_token from this JS object

This function does one of three things
If the 't' parameter is not passed in, the current value for the access_token value is returned.

Namespace Detail
Sfdc.canvas.oauth
Method Detail
checkChildWindowStatus()
Refreshes the parent window only if the child window is closed.

childWindowUnloadNotification(hash)
Parses the hash value that is passed in and sets the access_token and instance_url cookies if they exist. Use during User-Agent OAuth Authentication Flow to pass the OAuth token
Sfdc.canvas.oauth.childWindowUnloadNotification(self.location.hash);
Parameters:
{String} hash
Typically a string of key-value pairs delimited by the ampersand character.

{String} instance(i)
Sets, gets or removes the instance_url cookie

This function does one of three things
If the 'i' parameter is not passed in, the current value for the instance_url cookie is returned.
If the 'i' parameter is null, the instance_url cookie is removed.
Otherwise the instance_url cookie value is set to the 'i' parameter and then returned.

Parameters:
{String} i Optional
The value to set as the instance_url cookie
Returns:
{String} The resulting instance_url cookie value if set, otherwise null

{Boolean} loggedin()
Returns the login state
Returns:
{Boolean} true if the access_token is available in this JS object. Note: access tokens (i.e. OAuth tokens) should be stored server side for more durability. Never store OAuth tokens in cookies as this can lead to a security risk.

login(ctx)
Opens the OAuth popup window to retrieve an OAuth token
function clickHandler(e)
{
 var uri;
 if (! connect.oauth.loggedin())
 {
  uri = connect.oauth.loginUrl();
  connect.oauth.login(
   {uri : uri,
    params: {
     response_type : "token",
     client_id :  "<%=consumerKey%>",
     redirect_uri : encodeURIComponent("/sdk/callback.html")
     }});
 } else {
    connect.oauth.logout();
 }
 return false;
}
Parameters:
{Object} ctx
Context object that contains the url, the response type, the client id and callback url

{String} loginUrl()
Returns the url for the OAuth authorization service
Returns:
{String} The url for the OAuth authorization service or default if there is not a value for loginUrl in the current url's query string.

logout()
Removes the access_token oauth token from this object.

{String} token(t)
Sets, gets or removes the access_token from this JS object

This function does one of three things
If the 't' parameter is not passed in, the current value for the access_token value is returned.
If the the 't' parameter is null, the access_token value is removed.
Note: for longer term storage of the OAuth token store it server side in the session, access tokens should never be stored in cookies. Otherwise the access_token value is set to the 't' parameter and then returned.

Parameters:
{String} t Optional
The oauth token to set as the access_token value
Returns:
{String} The resulting access_token value if set, otherwise null

Documentation generated by JsDoc Toolkit 2.3.0 on Fri Jan 11 2013 16:00:16 GMT-0000 (GMT)