Search in sources :

Example 1 with TwitterConfig

use of com.twitter.sdk.android.core.TwitterConfig in project xabber-android by redsolution.

the class BaseLoginActivity method initTwitterAuth.

private void initTwitterAuth() {
    if (twitterAuthClient != null && twitterSessionCallback != null)
        return;
    TwitterConfig config = new TwitterConfig.Builder(this).logger(new DefaultLogger(Log.DEBUG)).twitterAuthConfig(new TwitterAuthConfig(getResources().getString(R.string.SOCIAL_AUTH_TWITTER_KEY), getResources().getString(R.string.SOCIAL_AUTH_TWITTER_SECRET))).debug(true).build();
    Twitter.initialize(config);
    twitterAuthClient = new TwitterAuthClient();
    twitterSessionCallback = new Callback<TwitterSession>() {

        @Override
        public void success(Result<TwitterSession> result) {
            String token = result.data.getAuthToken().token;
            String secret = result.data.getAuthToken().secret;
            if (token != null && secret != null) {
                String credentials = gson.toJson(new AuthManager.TwitterAccessToken(new AuthManager.TwitterTokens(secret, token), getResources().getString(R.string.SOCIAL_AUTH_TWITTER_SECRET), getResources().getString(R.string.SOCIAL_AUTH_TWITTER_KEY)));
                onSocialAuthSuccess(AuthManager.PROVIDER_TWITTER, credentials);
            }
        }

        @Override
        public void failure(TwitterException exception) {
            Toast.makeText(BaseLoginActivity.this, R.string.auth_twitter_error, Toast.LENGTH_SHORT).show();
        }
    };
}
Also used : TwitterSession(com.twitter.sdk.android.core.TwitterSession) AuthManager(com.xabber.android.data.xaccount.AuthManager) TwitterAuthConfig(com.twitter.sdk.android.core.TwitterAuthConfig) TwitterAuthClient(com.twitter.sdk.android.core.identity.TwitterAuthClient) DefaultLogger(com.twitter.sdk.android.core.DefaultLogger) TwitterException(com.twitter.sdk.android.core.TwitterException) TwitterConfig(com.twitter.sdk.android.core.TwitterConfig)

Aggregations

DefaultLogger (com.twitter.sdk.android.core.DefaultLogger)1 TwitterAuthConfig (com.twitter.sdk.android.core.TwitterAuthConfig)1 TwitterConfig (com.twitter.sdk.android.core.TwitterConfig)1 TwitterException (com.twitter.sdk.android.core.TwitterException)1 TwitterSession (com.twitter.sdk.android.core.TwitterSession)1 TwitterAuthClient (com.twitter.sdk.android.core.identity.TwitterAuthClient)1 AuthManager (com.xabber.android.data.xaccount.AuthManager)1