Namespace Sfdc.canvas.oauth
Sfdc.canvas.oauth
Defined in: oauth.js.
Constructor Attributes | Constructor Name and Description |
---|---|
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. |
|
instance(i)
Sets, gets or removes the
instance_url cookie This function does one of three things |
|
loggedin()
Returns the login state
|
|
login(ctx)
Opens the OAuth popup window to retrieve an OAuth token
|
|
loginUrl()
Returns the url for the OAuth authorization service
|
|
logout()
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 |
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.
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
- Returns:
- {Boolean}
true
if theaccess_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.
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
- 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.
access_token
oauth token from this object.
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