Reputation: 6466
I'm using the twitter gem for a Rails App, so that I can have my blog posts automatically updated onto my twitter feed.
I followed the gem readme instructions, throwing this in a config/initializers/twitter.rb file
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
updating those variables onto Heroku, signing up my application under my twitter account, giving the account read, write, and direct access, and then trying to update through the heroku console like so:
Twitter.update("Testing Twitter integration")
Unfortunately, I get this error:
Twitter::Error::Unauthorized: Could not authenticate you
(followed by these probably unhelpful details):
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/response/raise_error.rb:21:in `on_complete'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/response.rb:9:in `block in call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/response.rb:63:in `on_complete'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/response.rb:8:in `call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/request/url_encoded.rb:14:in `call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/request/multipart.rb:13:in `call'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/request/multipart_with_file.rb:14:in `call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/connection.rb:247:in `run_request'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/connection.rb:112:in `post'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/client.rb:81:in `request'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/client.rb:70:in `post'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/api/utils.rb:82:in `object_from_response'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/api/tweets.rb:129:in `update'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter.rb:52:in `method_missing'
from (irb):2
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):003:0>
Twitter's definitely authenticating me at least partially, because earlier, when I hadn't switched to read/write, it had complained that
Twitter::Error::Unauthorized: Error processing your OAuth request: Read-only application cannot POST
(To fix this, I both edited my settings and reset my OAuth keys).
I've Googled around, but I haven't had any luck finding other people in the same situation. Wondering whether I'm doing something wrong, or whether I just have to wait for a bit.
Any ideas?
Upvotes: 2
Views: 5616
Reputation: 9693
Have you provided a callback url?
That happened me with the new updates of twitter, and even I wasn't using the callback url from the app configuration, I was having the same problem until I updated it, I ended adding
http://www.my-website.com/auth/twitter/callback
Which I didn't even use for localhost development, yet it started to work after that.
Otherwise please update the question with your code/gems for twitter auth, and the settings you have on twitter, in that we we can review the code and let you know if there is something worng
Upvotes: 2