Volodymyr Machekhin
Volodymyr Machekhin

Reputation: 186

Can't logout from twitter with fabric, android

Please help me. I want to logout from twitter after logging in and getting access token. I want to login with multiple accounts.

TwitterAuthConfig authConfig =  new TwitterAuthConfig(CONSUMER_KEY, CONSUMER_SECRET);
Fabric.with(this, new TwitterCore(authConfig));



twitterButton = (TwitterLoginButton) findViewById(R.id.twitter_button);
twitterButton.setCallback(new Callback<TwitterSession>() {
    @Override
    public void success(Result<TwitterSession> result) {
        // Do something with result, which provides a TwitterSession for making API calls
        TwitterSession session = Twitter.getSessionManager().getActiveSession();
        TwitterAuthToken authToken = session.getAuthToken();

        String token = authToken.token;
        String secret = authToken.secret;
        Log.d("TWITTER", "token " + token);
        Log.d("TWITTER", "secret " + secret);
        Log.d("TWITTER", "name " + session.getUserName());

        CookieSyncManager.createInstance(ActivitySettings.this);
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.removeSessionCookie();
        Twitter.getSessionManager().clearActiveSession();
        Twitter.logOut();
    }

    @Override
    public void failure(TwitterException exception) {
        // Do something on failure
    }
});

Is there a way to clear session? Because the user has to click signout button to logout.

Thanks!

Upvotes: 2

Views: 864

Answers (1)

Volodymyr Machekhin
Volodymyr Machekhin

Reputation: 186

Maybe will usefull for someone. I found the answer after contqcting twitter support. They said that it is impossible to log in multiple accounts and user has to press logout into the webview to enter new auth data.

Upvotes: 1

Related Questions