Class KiiSocialNetworkConnector
- java.lang.Object
-
- com.kii.cloud.storage.social.connector.KiiSocialNetworkConnector
-
- All Implemented Interfaces:
KiiSocialConnect
public class KiiSocialNetworkConnector extends java.lang.Object implements KiiSocialConnect
Provides API that allows user to authenticate on KiiCloud through various social networks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KiiSocialNetworkConnector.Provider
Supported social network.-
Nested classes/interfaces inherited from interface com.kii.cloud.storage.social.KiiSocialConnect
KiiSocialConnect.SocialNetwork
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACCESS_TOKEN
static java.lang.String
ACCESS_TOKEN_SECRET
static java.lang.String
DISABLE_JAVASCRIPT
static java.lang.String
OPEN_ID
static java.lang.String
PROVIDER
static int
REQUEST_CODE
Request code that will send to your application throughActivity.onActivityResult(int, int, Intent)
to identify social authentication result.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description android.os.Bundle
getAccessTokenBundle()
Get the access token bundle of social network used for log-in.void
initialize(java.lang.String consumerKey, java.lang.String consumerSecret, android.os.Bundle options)
This method do nothing for KiiSocialNetworkConnector.void
link(android.app.Activity activity, android.os.Bundle options, KiiSocialCallBack callback)
Link current login user to social network specified in the bundle.void
logIn(android.app.Activity activity, android.os.Bundle options, KiiSocialCallBack callback)
Login with the social network specified in the bundle.
This method has two functions.void
logIn(android.app.Activity activity, KiiSocialNetworkConnector.Provider provider, KiiSocialCallBack callback)
Login with specified social network.This method is a shortcut oflogIn(Activity, Bundle, KiiSocialCallBack)
.
Note : You have to callrespondAuthOnActivityResult(int, int, Intent)
from youronActivityResult()
.void
respondAuthOnActivityResult(int requestCode, int resultCode, android.content.Intent data)
Following tologIn()
, your activityonActivityResult()
will be called.void
unlink(android.app.Activity activity, android.os.Bundle options, KiiSocialCallBack callback)
UnLink current login user to social network specified in the bundle.
-
-
-
Field Detail
-
PROVIDER
public static final java.lang.String PROVIDER
- See Also:
- Constant Field Values
-
ACCESS_TOKEN
public static final java.lang.String ACCESS_TOKEN
- See Also:
- Constant Field Values
-
ACCESS_TOKEN_SECRET
public static final java.lang.String ACCESS_TOKEN_SECRET
- See Also:
- Constant Field Values
-
OPEN_ID
public static final java.lang.String OPEN_ID
- See Also:
- Constant Field Values
-
DISABLE_JAVASCRIPT
public static final java.lang.String DISABLE_JAVASCRIPT
- See Also:
- Constant Field Values
-
REQUEST_CODE
public static final int REQUEST_CODE
Request code that will send to your application throughActivity.onActivityResult(int, int, Intent)
to identify social authentication result.- See Also:
- Constant Field Values
-
-
Method Detail
-
logIn
public void logIn(@Nullable android.app.Activity activity, @NonNull android.os.Bundle options, @NonNull KiiSocialCallBack callback)
Login with the social network specified in the bundle.
This method has two functions. The first one is to log in via UI login interface. The second is to log in using access token. Note : If you want to login via UI login interface, you have to callrespondAuthOnActivityResult(int, int, Intent)
from youronActivityResult()
. Otherwise, callback would not be called.
Note : This API can not use token expiration feature.- Specified by:
logIn
in interfaceKiiSocialConnect
- Parameters:
activity
- which invokes login procedure.Not Required to login with access token.options
- following parameters can be assigned to bundle:KEY VALUE-TYPE VALUE NOTE provider KiiSocialNetworkConnector.Provider
Social network to use. KiiSocialNetworkConnector.Provider.QQ
is not supported with UI login interface. Please provide accessToken and openID to integrate QQ.accessToken String Access token issued by SNS. accessTokenSecret String Access token secret issued by Twitter. openID String OpenID of QQ user. Required disableJavascript Boolean Disable javascript of webview when login with UI. False by default. callback
- notifies events asynchronously.- Throws:
java.lang.IllegalArgumentException
- Thrown if- Specified bundle is null or does not contain key 'provider' or the value type is not
KiiSocialNetworkConnector.Provider
. Or value of 'disableJavascript' is not Boolean.- Specified callback is null.
- Specified bundle is null or does not contain key 'provider' or the value type is not
java.lang.UnsupportedOperationException
- Thrown if specified provider is not supported.- See Also:
KiiFacebookConnect.logIn(Activity, Bundle, KiiSocialCallBack)
,KiiTwitterConnect.logIn(Activity, Bundle, KiiSocialCallBack)
,KiiQQConnect.logIn(Activity, Bundle, KiiSocialCallBack)
-
logIn
public void logIn(@NonNull android.app.Activity activity, @NonNull KiiSocialNetworkConnector.Provider provider, @NonNull KiiSocialCallBack callback)
Login with specified social network.This method is a shortcut oflogIn(Activity, Bundle, KiiSocialCallBack)
.
Note : You have to callrespondAuthOnActivityResult(int, int, Intent)
from youronActivityResult()
. Otherwise, callback would not be called.- Parameters:
activity
- which invokes login procedure.provider
- Social network to use.callback
- notifies events asynchronously.- Throws:
java.lang.IllegalArgumentException
- Thrown if- Specified activity is null.
- Specified provider is null.
- Specified callback is null.
java.lang.UnsupportedOperationException
- Thrown if specified provider is not supported.
-
link
public void link(@Nullable android.app.Activity activity, @NonNull android.os.Bundle options, @NonNull KiiSocialCallBack callback)
Link current login user to social network specified in the bundle.- Specified by:
link
in interfaceKiiSocialConnect
- Parameters:
activity
- which invokes this procedure.options
- following parameters can be assigned to bundle:KEY VALUE-TYPE VALUE NOTE provider KiiSocialNetworkConnector.Provider
Social network to use. accessToken String Access token issued by SNS. accessTokenSecret String Access token secret issued by Twitter. openID String OpenID of QQ user. Required callback
- notifies event asynchronously.- See Also:
KiiFacebookConnect.link(Activity, Bundle, KiiSocialCallBack)
,KiiTwitterConnect.link(Activity, Bundle, KiiSocialCallBack)
,KiiQQConnect.link(Activity, Bundle, KiiSocialCallBack)
-
unlink
public void unlink(@Nullable android.app.Activity activity, @NonNull android.os.Bundle options, @NonNull KiiSocialCallBack callback)
UnLink current login user to social network specified in the bundle.- Specified by:
unlink
in interfaceKiiSocialConnect
- Parameters:
activity
- which invokes this procedure.options
- following parameters can be assigned to bundle:KEY VALUE-TYPE VALUE NOTE provider KiiSocialNetworkConnector.Provider
Social network to use. callback
- notifies event asynchronously.- See Also:
KiiFacebookConnect.unlink(Activity, Bundle, KiiSocialCallBack)
,KiiTwitterConnect.unlink(Activity, Bundle, KiiSocialCallBack)
,KiiQQConnect.unlink(Activity, Bundle, KiiSocialCallBack)
-
respondAuthOnActivityResult
public void respondAuthOnActivityResult(int requestCode, int resultCode, @NonNull android.content.Intent data)
Following tologIn()
, your activityonActivityResult()
will be called. You need to call this method inside, otherwise login will not be completed.- Specified by:
respondAuthOnActivityResult
in interfaceKiiSocialConnect
- Parameters:
requestCode
- passed fromonActivityResult()
resultCode
- passed fromonActivityResult()
data
- passed fromonActivityResult()
-
getAccessTokenBundle
@Nullable public android.os.Bundle getAccessTokenBundle()
Get the access token bundle of social network used for log-in. Bundle contains:Key Type Value Note "oauth_token" String Required for accessing social network API. "oauth_token_secret" String Required to generate signature when you call social network API. Present in the bundle for Twitter, LinkedIn, and Yahoo. "openID" String Required for accessing QQ API. Present in the bundle for QQ "provider_user_id" String User id provided by social network. ex.) 'xoauth_yahoo_guid' used by Yahoo profile API. This value is set only when you use the UI login interface. Otherwise you need to get this ID using KiiUser#getLinkedSocialAccounts. "kii_new_user" Boolean True if a new KiiUser has created, false if linked existing user with social network. "oauth_token_expires_in" Long Social provider's token expiration time. "id_token" String ID token provided by OpenID Provider. This field is provided when KiiSocialNetworkConnector.Provider.OPENID_CONNECT_SIMPLE
is used."refresh_token" String Refresh token provided by OpenID Provider. This field is provided when KiiSocialNetworkConnector.Provider.OPENID_CONNECT_SIMPLE
is used and configured OpenID Provider supports refresh token.- Specified by:
getAccessTokenBundle
in interfaceKiiSocialConnect
- Returns:
- Access token bundle. null when not logged in or linked with social network.
- See Also:
KiiFacebookConnect.getAccessTokenBundle()
,KiiTwitterConnect.getAccessTokenBundle()
,KiiQQConnect.getAccessTokenBundle()
-
initialize
public void initialize(@Nullable java.lang.String consumerKey, @Nullable java.lang.String consumerSecret, @Nullable android.os.Bundle options)
This method do nothing for KiiSocialNetworkConnector. It is not necessary to call.- Specified by:
initialize
in interfaceKiiSocialConnect
- Parameters:
consumerKey
- Consumer key given by social network.consumerSecret
- Consumer secret given by social network.options
- defined by each social network.- See Also:
KiiFacebookConnect.initialize(String, String, Bundle)
,KiiTwitterConnect.initialize(String, String, Bundle)
,KiiQQConnect.initialize(String, String, Bundle)
-
-