Class 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.
    • Field Detail

      • ACCESS_TOKEN_SECRET

        public static final java.lang.String ACCESS_TOKEN_SECRET
        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 through Activity.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 call respondAuthOnActivityResult(int, int, Intent) from your onActivityResult(). Otherwise, callback would not be called.
        Note : This API can not use token expiration feature.
        Specified by:
        logIn in interface KiiSocialConnect
        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.
      • 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 of logIn(Activity, Bundle, KiiSocialCallBack).
        Note : You have to call respondAuthOnActivityResult(int, int, Intent) from your onActivityResult(). 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 interface KiiSocialConnect
        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 interface KiiSocialConnect
        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 to logIn(), your activity onActivityResult() will be called. You need to call this method inside, otherwise login will not be completed.
        Specified by:
        respondAuthOnActivityResult in interface KiiSocialConnect
        Parameters:
        requestCode - passed from onActivityResult()
        resultCode - passed from onActivityResult()
        data - passed from onActivityResult()
      • 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 interface KiiSocialConnect
        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 interface KiiSocialConnect
        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)