Skip to content
This repository

request_token broken? #30

Closed
rlex opened this Issue · 7 comments

4 participants

Lex Rivera Alex Deva Gustaf Lindqvist Richard Taylor
Lex Rivera

request_token = client.request_token(:oauth_callback => 'YOUR_CALLBACK_URL')

says that i can't have arguments for request_token method

Alex Deva

Apparently now request_token does allow parameters, but not very usefully, as any attempt to get a request_token with a callback URL results in 401.

If I don't use the callback argument I can authenticate using PIN, but that's not practical for my web app.

Alex Deva

I fixed the 401 issue by setting up a placeholder callback URL in the app settings -- apparently Twitter assumes otherwise it's a desktop app, I found this out by inspecting the actual body of the 401 response -- so now I can grant access rights to my app, but still it works PIN-based (even though I've clearly specified a callback URL in request_token too).

Gustaf Lindqvist

I have the same problem with 401 issue. OAuth::Unauthorized at request_token.

alxx: I new to Ruby and Sinatra. How did you construct your placeholder?

I fixed the 401 issue by setting up a placeholder callback URL in the app settings

Alex Deva

Hi Gustaf. By "app settings" I meant the Twitter app settings -- in the Twitter website, where you created your app and you can now edit settings for it.

Just type any valid URL in the callback field. As long as you specify it when you request the token from Ruby, the one in the Twitter app settings will be ignored.

Gustaf Lindqvist

I getting 401 OAuth::Unauthorized at request_token. I have already added a URL in the callback field via Twitter app settings.

  # Error /foo/twitter_output.rb in block in <class:TwitterApp>

  # store the request tokens and send to Twitter
  get '/connect' do
    request_token = @client.request_token(
      :oauth_callback => ENV['CALLBACK_URL'] || @@config['callback_url']
    )

    session[:request_token] = request_token.token
    session[:request_token_secret] = request_token.secret
    redirect request_token.authorize_url.gsub('authorize', 'authenticate') 
  end
Alex Deva

No idea why you're replacing 'authorize' with 'authenticate'. It works fine for me with the default authorize_url.

Gustaf Lindqvist

alxx:

No idea why you're replacing 'authorize' with 'authenticate'. It works fine for me with the default authorize_url.

Problem is that request_token is failing before authorize_url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.