Reputation: 93
I'm using the Twitter gem to try and post a list of tweets from an account on my webpage, however I keep getting the 'Unable to verify your credentials' error.
I've even put the |config| block in the controller to try and narrow down what's going on, but no donut!
The Twitter keys are correct. I just created an app and copy / pasted them directly into the config/application.yml file. And then when it didn't work, I created a new app and tried again.
config/application.rb
require File.expand_path('../boot', __FILE__)
require 'yaml'
require 'rails/all'
config = YAML.load(File.read(File.expand_path('../application.yml', __FILE__)))
config/application.yml
TWITTER_CONSUMER_KEY: '123456789'
TWITTER_CONSUMER_SECRET: '123456789'
TWITTER_ACCESS_TOKEN: '123456789'
TWITTER_ACCESS_SECRET: '123456789'
app/controllers/pages.html.erb
class PagesController < ApplicationController
def index
@twitter = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
config.access_token_secret = ENV['TWITTER_ACCESS_SECRET']
end
@twitter.user_timeline("gem")
end
def help
end
end
Error Page:
Twitter::Error::Forbidden in PagesController#index
Unable to verify your credentials
Extracted source (around line #12):
end
@twitter.user_timeline("gem")
end
There's something simple I'm screwing up, I'm sure of it. I really have no idea what I'm doing wrong though.
Thanks in advance!
Upvotes: 0
Views: 1073
Reputation: 2357
@H-Dog please clarify. In using the application.yml, are you configuring it from the application.rb with config = YAML.load(File.read(File.expand_path('../application.yml', __FILE__)))
? and
are you sure you don't want to do twitter-auth to get necessary credentials (access_token and access_secret) for the account you want to tweet from?
Upvotes: 0