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.
 
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 JavaScript object.
Namespace Detail
Sfdc.canvas.oauth
Method Detail
checkChildWindowStatus()
Refreshes the parent window only if the child window is closed. This method is no longer used. Leaving in for backwards compatability.

childWindowUnloadNotification(hash)
Parses the hash value that is passed in and sets the access_token and instance_url cookies if they exist. Use this method during User-Agent OAuth Authentication Flow to pass the OAuth token.
Sfdc.canvas.oauth.childWindowUnloadNotification(self.location.hash);
Parameters:
{String} hash
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:
1) If the 'i' parameter is not passed in, the current value for the instance_url cookie is returned.
2) If the 'i' parameter is null, the instance_url cookie is removed.
3) 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 (for example, 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
The context object that contains the URL, the response type, the client ID, and the 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's no 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 JavaScript object.

This function does one of three things:
1) If the 't' parameter isn't passed in, the current value for the access_token value is returned.
2) If the the 't' parameter is null, the access_token value is removed.
3) Otherwise the access_token value is set to the 't' parameter and then returned.

Note: for longer-term storage of the OAuth token, store it server-side in the session. Access tokens should never be stored in cookies.

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.4.0 on Tue Jul 15 2014 13:44:12 GMT-0700 (PDT)