Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3427546
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:51:00+00:00 2026-05-18T06:51:00+00:00

Jnunemaker just updated his twitter gem (https://github.com/jnunemaker/twitter) and removed the Twitter::Oauth class. My code

  • 0

Jnunemaker just updated his twitter gem (https://github.com/jnunemaker/twitter) and removed the Twitter::Oauth class. My code doesn’t look much like his example, so I’m having issues updating it. Here’s what my code used to look with the twitter 0.9 gem:

UsersController

def oauth
  consumer = Twitter::OAuth.new('mykey','mysecret')
  request_token = consumer.request_token  
  session[:request_token] = request_token.token  
  session[:request_token_secret] = request_token.secret
  redirect_to 'http://api.twitter.com/oauth/authorize?oauth_token='+request_token.token
end

def callback
  consumer = Twitter::OAuth.new('mykey','mysecret')
  atoken, asecret = oauth.authorize_from_request(session[:request_token], session[:request_token_secret], params[:oauth_verifier])  
  consumer.authorize_from_access(atoken,asecret)
  user = Twitter::Base.new(consumer).verify_credentials

  #and then I create a new user in my application, with attributes such as the user's follower count, etc
end

Here’s an example of what I’ve tried to do to change this code:

UsersController

def oauth
  consumer = OAuth::Consumer.new("mykey", "mysecret", :site => "siteurl")
  request_token = consumer.get_request_token
  session[:request_token] = request_token.token  
  session[:request_token_secret] = request_token.secret
  redirect_to 'http://api.twitter.com/oauth/authorize?oauth_token='+request_token.token
end

def callback
  consumer = OAuth::Consumer.new("mykey", "mysecret", :site => "siteurl")
  request_token = session[:request_token]
  atoken = OAuth::RequestToken.new(consumer, request_token.token, request_token.secret).get_access_token(:oauth_verifier => params[:oauth_verifier])
  consumer.authorize_from_access(atoken)
  user = Twitter::Client.new(consumer).verify_credentials

Gemfile

...
gem 'oauth'

I’m sure there are a number of things wrong in my callback method, but one thing that’s weird is that my oauth method works fine when I’m running locally, but gives me a ‘502 Bad Gateway’ error when I try from my live (deployed with heroku) version.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:51:00+00:00Added an answer on May 18, 2026 at 6:51 am

    If you can’t get it to work with what you have now, I have been able to use the Omniauth gem together with the Twitter gem. Omniauth is very easy to setup.

    To use the Twitter gem, just get the access token info after the Omniauth callback is done:

    token = omniauth['credentials']['token'], 
    secret = omniauth['credentials']['secret']
    

    Then just set the Twitter gem config settings before using the Twitter gem methods

    Twitter.oauth_token = token
    Twitter.oauth_token_secret = secret
    
    Twitter.home_timeline.first.text
    

    (You’ll have to configure the Twitter gem consumer_key and consumer_key_secret if you don’t haven’t that already set up in an initializer file…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.