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();
}
};
}
Aggregations