twitteroauth – Force User Login

twitteroauth is the first PHP Library to support OAuth for Twitter’s REST API. It is developed by Abraham Williams. You can download the source code @ GitHub and the example inside is quite easy to follow.
GitHub – abraham / twitteroauth

Unlike the Facebook API, the Twitter API does not support logout. If you want to increase the security, you can force user login every time when he/she clicks the Signin with Twitter button. This can be down by adding the force_login parameter in the GET oauth/authenticate request.
Twitter API – GET oauth/authenticate

Append the force_login parameter in the getAuthorizeURL() function.

   * Get the authorize URL
   * @returns a string
  function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
    if (is_array($token)) {
      $token = $token['oauth_token'];
    if (empty($sign_in_with_twitter)) {
      //return $this->authorizeURL() . "?oauth_token={$token}";
      return $this->authorizeURL() . "?oauth_token={$token}" . "&force_login=true";
    } else {
      //return $this->authenticateURL() . "?oauth_token={$token}";
      return $this->authenticateURL() . "?oauth_token={$token}" . "&force_login=true";


Thanks Abraham Williams for his work on twitteroauth.

Done =)


2 thoughts on “twitteroauth – Force User Login”

  1. Thanks for the solution.But could you come out with a possible solution for this problem:When a visitor logs out from the website via Twitter, he is not logged out from twitter website itself. This phenomena doesnt occur in other Oauth Social Logins.Your feedback would benefit not only me but million developers.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.