Twitter API – Logout

The session with Twitter is defined by a cookie owned by Twitter — something you do not have control over. You cannot log them out of Twitter on their behalf.

If you want someone to be able to use your “switch twitter account” functionality, you’ll need to pass them off to the OAuth handshake again, but use the /oauth/authorize path instead of the /oauth/authenticate path. This will allow the user to switch their user credentials at Twitter during the handshake instead of just re-authenticating using their existing Twitter session.

Alternatively, you could have a separate notion of users in your own app whereby you have your own user model that has many twitter accounts associated with it. That way, you could allow your users to switch accounts more seemlessly. They would have to authorize your app up front for each of their twitter accounts, but you would have all their oauth keys for each of their twitter accounts after that.

Leave a Comment