client.authorized? returns false for valid clients #38

Closed
arbesulo opened this Issue Oct 11, 2012 · 5 comments

Comments

Projects
None yet
4 participants

Hi,

I'm having problems with the client.authorized? method. I have realized that returns false even when the client is a valid one. Here are the last steps of my client set up:

client = TwitterOAuth::Client.new({:consumer_key => config.consumer_key, :consumer_secret => config.consumer_secret, :token => access_token.token, :secret => access_token.secret }

client.authorized?
=> false

client.update("test!")
{"id"=>256373778823671808, .... }

This was working until recently... did I miss some update?
Thanks in advance!

GabGab commented Oct 11, 2012

Hi, I actually have the exact same problem and have been struggling with this all afternoon. Today all of a sudden we can no longer use our twitter connect button because of a 401 Unauthorized response gotten from this line :

  @access_token = @client.authorize(twitter_session[:temporary_token], twitter_session[:temporary_secret], {
    :oauth_verifier => params[:oauth_verifier]
  })

We have correctly configured a callback url in our twitter App (the connect used to work perfectly until today).

Just to make things clear, our workflow is the following :

First we do :

@client = TwitterOAuth::Client.new(
      :consumer_key => SocialNetworkConfig.twitter.consumer_key,
      :consumer_secret => SocialNetworkConfig.twitter.consumer_secret
  )
 request_token = @client.authentication_request_token(:oauth_callback => create_twitter_session_url(:protocol => "http#{'s' if Rails.env.production?}"))

 twitter_session[:temporary_token] = request_token.token
  twitter_session[:temporary_secret] = request_token.secret

  redirect_to request_token.authorize_url

Then once the app has been authorized via twitter :

@client = TwitterOAuth::Client.new({
    :consumer_key => SocialNetworkConfig.twitter.consumer_key,
    :consumer_secret => SocialNetworkConfig.twitter.consumer_secret
  })

  @access_token = @client.authorize(twitter_session[:temporary_token], twitter_session[:temporary_secret], {
    :oauth_verifier => params[:oauth_verifier]
  })

 @client.authorized?

The last line returns false when we have perfectly valid users that are known to have accepted permissions. Through our debugging we have determined that the issue does not come from our code, maybe Twitter changed the way it's communicating this type of info ?

Thanks again for any help you can provide ! Take care

We've also had this problem since morning. Changing the path in TwitterOauth::Client.authorized? "/1/account/verify_credentials.json" fixed it.

GabGab commented Oct 12, 2012

I see, to change this you had to unpack, modify and then rebuild the gem ?

Owner

moomerman commented Oct 12, 2012

Just pushed v0.4.4 with this fix in. Thanks!

moomerman closed this Oct 12, 2012

GabGab commented Oct 12, 2012

It works perfectly now, thanks for your fast reaction :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment