Rails - Twitter :: Error :: BadRequest (bad authentication data) - After deployment in Heroku

In my application, I provide users with tweets with the following code:

if twitter = current_user.authentications.find_by_provider("twitter") Twitter.configure do |tw| tw.consumer_key = "6jaqMt7kE9iVxh8hX0mmtQ" tw.consumer_secret = "5ZIydxRBFfEJxc2EzedahIxoeO8g1hZCQVqZFtWWNM" tw.oauth_token = twitter.token tw.oauth_token_secret = twitter.token_secret end Twitter.update(params[:tweet]) 

It works well in my localhost. However, now I have deployed my application to heroku and I am trying to send tweets, but in heroku logs it says:

 2012-11-15T01:30:32+00:00 app[web.1]: Completed 500 Internal Server Error in 494ms 2012-11-15T01:30:32+00:00 app[web.1]: 2012-11-15T01:30:32+00:00 app[web.1]: Twitter::Error::BadRequest (Bad Authentication data): 2012-11-15T01:30:32+00:00 app[web.1]: 2012-11-15T01:30:32+00:00 app[web.1]: 2012-11-15T01:30:32+00:00 app[web.1]: app/controllers/posts_controller.rb:12:in `create' 

What should I do to solve this problem?

Thanks.

+4
source share
2 answers

I found out Twitter authentication and wrote a tutorial with experience: http://www.orhancanceylan.com/rails-twitter-and-facebook-authentications-with-omniauth-and-devise/

-1
source

Two things:

  • Update the callback URL on your production server in your registered Twitter app settings.

  • If you are using the herokuapp.com subdomain, guess what you are using in the pool of other Twitter API requests. Proxy your API requests through Apigee .

  • Initialize and then transfer your database to Heroku through the console:

    heroku run rake db:setup

    heroku run rake db:migrate

(usually just rake db: migrate works, but in this case I had to do both)

Retrieved from discussion on Twitter Dev

0
source

Source: https://habr.com/ru/post/1446114/


All Articles