yevgenko
(Yevhen Viktorov)
September 8, 2013, 5:21pm
1
Twitter::Error::Forbidden:
Unable to verify your credentials
At least consumer key and secret are required, and that’s easy to fix:
Register your application with twitter
Put consumer key and secret into environment variables:
export CONSUMER_KEY=123
export CONSUMER_SECRET=secret
or use GitHub - bkeepers/dotenv: A Ruby gem to load environment variables from `.env`. instead
Add the following to config/initializers/twitter.rb
:
Twitter.configure do |config|
config.consumer_key = ENV['CONSUMER_KEY']
config.consumer_secret = ENV['CONSUMER_SECRET']
end
Happy Testing
3 Likes
patrikbona
(Patrik Bóna)
September 20, 2013, 8:49am
3
Please note that this is not working with newer version of twitter gem (version 5), so make sure to use 4.8.1 and it will work.
Also at first glance it looks that twitter gem API has been changed, so make sure to use version 4.8.1 if you are working on TDD workshop.
1 Like
Hi wik, thanks for your post. I’m doing the TDD workshop and I’m stuck on this Twitter::Error::Forbidden error
Someting is not clear to me, in what file do I need to put those environment variables?
Thanks for your help,
Anthony
solved it with the .dotenv gem
yevgenko
(Yevhen Viktorov)
November 17, 2013, 10:56am
6
just type the following within your current bash session before running the specs:
export CONSUMER_KEY=123
export CONSUMER_SECRET=secret
or prepend to the actual command, e.g.:
CONSUMER_KEY=123 CONSUMER_SECRET=secret bundle exec rails s
But yeah, dotenv is a solid solution
1 Like
ozdigennaro
(Oz DiGennaro)
December 27, 2013, 11:39pm
7
Thanks very much. Your suggestions worked for me, even rather quickly.
Ah, what a world: create a application authentication, hide it from the app, configure the gem.
Then, only then do we ge the tweets.
Oh well.
Second @patrikbona : The v5 of the twitter gem breaks almost everything that was working in v4.
lgrains
(Louise Rains)
June 14, 2014, 5:44pm
9
It should be noted that the consumer_key and consumer_secret are called the API key and API secret in today’s (2014-06-14) version of creating your twitter application.