views:

44

answers:

1

I'm having a pretty bizarre and frustrating problem with Twitter's API. The oauth process is working just fine locally but once I put the site on heroku it automatically adds the url of the testing server and redirects to a broken page. This is the code:

  def oauth
    oauth = Twitter::OAuth.new('*','*')
    request_token = oauth.request_token(:oauth_callback => 'http://strong-ice-53.heroku.com/callback')  
    session[:request_token] = request_token.token  
    session[:request_token_secret] = request_token.secret  
    session[:returnurl] = params[:returnurl]
    redirect_to request_token.authorize_url
  end

Locally http://strong-ice-53.heroku.com/oauth sends me to api.twitter.com/... just fine. but once online it sends me to http://strong-ice-53.heroku.comapi.twitter.com/... which gives me an error.

I've tried chomping the redirect but that doesn't seem to work:

redirect_to request_token.authorize_url.chomp("strong-ice-53.heroku.com")

Any help would be greatly appreciated. I'm a noob to all of this.

A: 

Which version of twitter oauth are you using? That looks like a bug in oauth to me.

Also can you please inspect the content of the variable request_token.authorize_url? Something like this should do the trick:

def oauth
    oauth = Twitter::OAuth.new('*','*')
    request_token = oauth.request_token(:oauth_callback => 'http://strong-ice-53.heroku.com/callback')  
    session[:request_token] = request_token.token  
    session[:request_token_secret] = request_token.secret  
    session[:returnurl] = params[:returnurl]
    logger.info("\n\n\n\n#{request_token.authorize_url.inspect}\n\n\n\n")
    redirect_to request_token.authorize_url
end

And then watch the server for the output

Oscar Del Ben