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. |
|
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 JavaScript object. |
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.
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
- Returns:
- {Boolean}
true
if theaccess_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.
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
- 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
access_token
OAuth token from this object.
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