Class KiiSocialConnect
Represents a KiiSocialConnect object
Defined in: KiiSDK.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
KiiSocialConnect.getAccessTokenExpirationForNetwork(networkName)
Retrieve the current user's access token expiration date from a social network
The network must be set up and linked to the current user.
|
<static> |
KiiSocialConnect.getAccessTokenForNetwork(networkName)
Retrieve the current user's access token from a social network
The network must be set up and linked to the current user.
|
<static> |
KiiSocialConnect.getAccessTokenObjectForNetwork(networkName)
Retrieve the current user's access token object from a social network
The network must be set up and linked to the current user.
|
<static> |
KiiSocialConnect.linkCurrentUserWithNetwork(networkName, options, callbacks)
Link the currently logged in user with a social network
This will initiate the login process for the given network, which for SSO-enabled services like Facebook, will send the user to the Facebook site for authentication.
|
<static> |
KiiSocialConnect.logIn(networkName, options, callbacks)
Log a user into the social network provided
This will initiate the login process for the given network.
|
<static> |
KiiSocialConnect.setupNetwork(networkName, apiKey, apiSecret, extras)
|
<static> |
KiiSocialConnect.unLinkCurrentUserFromNetwork(networkName, callbacks)
Unlink the currently logged in user with a social network
The network must already be set up via setupNetwork
|
Method Detail
<static>
{String}
KiiSocialConnect.getAccessTokenExpirationForNetwork(networkName)
Retrieve the current user's access token expiration date from a social network
The network must be set up and linked to the current user. It is recommended you save this to preferences for multi-session use.
- Parameters:
- networkName
- One of the supported KiiSocialNetworkName values
- Deprecated:
- Use KiiSocialConnect.getAccessTokenObjectForNetwork instead.
- Returns:
- {String} The current access token expiration date, null if unavailable
<static>
{String}
KiiSocialConnect.getAccessTokenForNetwork(networkName)
Retrieve the current user's access token from a social network
The network must be set up and linked to the current user. It is recommended you save this to preferences for multi-session use.
- Parameters:
- networkName
- One of the supported KiiSocialNetworkName values
- Deprecated:
- Use KiiSocialConnect.getAccessTokenObjectForNetwork instead.
- Returns:
- {String} The current access token, null if unavailable
<static>
{Object}
KiiSocialConnect.getAccessTokenObjectForNetwork(networkName)
Retrieve the current user's access token object from a social network
The network must be set up and linked to the current user.
It is recommended you save this to preferences for multi-session use.
Following parameters can be assigned to object.
Facebookaccess_token
expires_in
kii_new_user
Twitteroauth_token
oauth_token_secret
kii_new_user
Googleaccess_token
kii_new_user
QQaccess_token
openID
kii_new_user
Following parameters can be assigned to object.
- Parameters:
- networkName
- One of the supported KiiSocialNetworkName values
- Returns:
- {Object} tokenObject The current access token object, null if unavailable.
<static>
{Promise}
KiiSocialConnect.linkCurrentUserWithNetwork(networkName, options, callbacks)
Link the currently logged in user with a social network
This will initiate the login process for the given network, which for SSO-enabled services like Facebook, will send the user to the Facebook site for authentication. There must be a currently authenticated KiiUser. Otherwise, you can use the logIn: method to create and log in a KiiUser using a network. The network must already be set up via setupNetwork
If there is not logged-in user to link with, callbacks.failure or reject callback of promise will be called.
If the opitons is invalid, callbacks.failure or reject callback of promise will be called.
If there is not logged-in user to link with, callbacks.failure or reject callback of promise will be called.
If the opitons is invalid, callbacks.failure or reject callback of promise will be called.
// example to use callbacks directly // Example of using no option KiiSocialConnect.linkCurrentUserWithNetwork(KiiSocialNetworkName.FACEBOOK, null, { success: function(user, network) { // do something now that the user is linked }, failure: function(user, network, anErrorString) { // do something with the error response } }); // example to use Promise // Example of using no option KiiSocialConnect.linkCurrentUserWithNetwork(KiiSocialNetworkName.FACEBOOK, null).then( function(params) { // do something now that the user is linked }, function(error) { // do something with the error response } );
- Parameters:
- networkName
- One of the supported KiiSocialNetworkName values
- options
- A dictionary of key/values to pass to KiiSocialConnect
FacebookKey Value type Value Note access_token String Access token of Facebook. This is mandatory.
TwitterKey Value type Value Note oauth_token String OAuth access token of twitter. This is mandatory. oauth_token_secret String OAuth access token secret of twitter. This is mandatory.
GoogleKey Value type Value Note access_token String Access token of Google. This is mandatory.
QQKey Value type Value Note access_token String Access token of QQ. This is mandatory. openID String OpenID of QQ. This is mandatory. - {Object} callbacks Optional
- An object with callback methods defined
- {Method} callbacks.success
- The callback method to call on a successful log in request
- {Method} callbacks.failure
- The callback method to call on a failed log in request
- Returns:
- {Promise} return promise object.
- fulfill callback function: function(params). params is Array instance.
- params[0] is a linked KiiUser instance.
- params[1] is the KiiSocialNetworkName used to link.
- reject callback function: function(error). error is an Error instance.
- error.target is current logged-in KiiUser instance. If there is not logged-in user, it will be null.
- error.message
- error.network is the KiiSocialNetworkName used to link.
- fulfill callback function: function(params). params is Array instance.
<static>
{Promise}
KiiSocialConnect.logIn(networkName, options, callbacks)
Log a user into the social network provided
This will initiate the login process for the given network. If user has already linked with the specified social network,
sign-in with the social network. Otherwise, this will sign-up and create new user authenticated by the specified social network.
If sign-up successful, the user is cached inside SDK as current user,and accessible via KiiUser.getCurrentUser().
User token and token expiration is also cached and can be get by KiiUser#getAccessTokenObject().
Access token won't be expired unless you set it explicitly by Kii.setAccessTokenExpiration().
The network must already be set up via setupNetwork
If the opitons is invalid, callbacks.failure or reject callback of promise will be called.
If the opitons is invalid, callbacks.failure or reject callback of promise will be called.
// example to use callbacks directly // Example of using no option KiiSocialConnect.logIn(KiiSocialNetworkName.FACEBOOK, null, { success: function(user, network) { // do something now that the user is logged in }, failure: function(user, network, anErrorString) { // do something with the error response } }); // example to use Promise KiiSocialConnect.logIn(KiiSocialNetworkName.FACEBOOK, null).then( function(params) { // do something now that the user is logged in }, function(error) { // do something with the error response } );
- Parameters:
- networkName
- One of the supported KiiSocialNetworkName values
- options
- A dictionary of key/values to pass to KiiSocialConnect
FacebookKey Value type Value Note access_token String Access token of Facebook. This is mandatory.
TwitterKey Value type Value Note oauth_token String OAuth access token of twitter. This is mandatory. oauth_token_secret String OAuth access token secret of twitter. This is mandatory.
GoogleKey Value type Value Note access_token String Access token of Google. This is mandatory.
QQKey Value type Value Note access_token String Access token of QQ. This is mandatory. openID String OpenID of QQ. This is mandatory. - {Object} callbacks Optional
- An object with callback methods defined
- {Method} callbacks.success
- The callback method to call on a successful log in request
- {Method} callbacks.failure
- The callback method to call on a failed log in request
- Returns:
- {Promise} return promise object.
- fulfill callback function: function(params). params is Array instance.
- params[0] is a logged in KiiUser instance.
- params[1] is the KiiSocialNetworkName used to login.
- reject callback function: function(error). error is an Error instance.
- error.message
- error.network is the KiiSocialNetworkName used to login.
- fulfill callback function: function(params). params is Array instance.
<static>
KiiSocialConnect.setupNetwork(networkName, apiKey, apiSecret, extras)
- Parameters:
- {KiiSocialNetworkName} networkName
- One of the supported KiiSocialNetworkName values
- {String} apiKey
- The SDK key assigned by the social network provider. For details refer to the table above.
- {String} apiSecret
- The SDK secret assigned by the social network provider. For details refer to the table above.
- {Object} extras
- Extra options that should be passed to the SNS. For details refer to the table above.
- Deprecated:
-
You don't have to call this method.
Set up a reference to one of the supported KiiSocialNetworks.
Set up the network. Need to be called before accessing other methods.
FacebookArgument Value Type Value Note networkName Number KiiSocialNetworkName.FACEBOOK Specify Facebook apiKey String null Facebook does not requires this argument. apiSecret String null Facebook does not requires this argument. extras Object null Facebook does not requires this argument.
TwitterArgument Value Type Value Note networkName Number KiiSocialNetworkName.TWITTER Specify Twitter apiKey String null Twitter does not requires this argument. apiSecret String null Twitter does not requires this argument. extras Object null Twitter does not requires this argument.
QQArgument Value Type Value Note networkName Number KiiSocialNetworkName.QQ Specify QQ apiKey String null QQ does not requires this argument. apiSecret String null QQ does not requires this argument. extras Object null QQ does not requires this argument.
- Throws:
- {InvalidArgumentException}
- For details refer to the table above
<static>
{Promise}
KiiSocialConnect.unLinkCurrentUserFromNetwork(networkName, callbacks)
Unlink the currently logged in user with a social network
The network must already be set up via setupNetwork
// example to use callbacks directly KiiSocialConnect.unLinkCurrentUserFromNetwork(KiiSocialNetworkName.FACEBOOK, { success: function(user, network) { // do something now that the user is unlinked }, failure: function(user, network, anErrorString) { // do something with the error response } }); // example to use Promise KiiSocialConnect.unLinkCurrentUserFromNetwork(KiiSocialNetworkName.FACEBOOK).then( function(params) { // do something now that the user is unlinked }, function(error) { // do something with the error response } );
- Parameters:
- networkName
- One of the supported KiiSocialNetworkName values
- {Object} callbacks Optional
- An object with callback methods defined
- {Method} callbacks.success
- The callback method to call on a successful log in request
- {Method} callbacks.failure
- The callback method to call on a failed log in request
- Returns:
- {Promise} return promise object.
- fulfill callback function: function(params). params is Array instance.
- params[0] is a unlinked KiiUser instance.
- params[1] is the KiiSocialNetworkName used to unlink.
- reject callback function: function(error). error is an Error instance.
- error.target is current logged-in KiiUser instance. If there is not logged-in user, it will be null.
- error.message
- error.network is the KiiSocialNetworkName used to unlink.
- fulfill callback function: function(params). params is Array instance.