本文介绍了Twitter :: Error :: Forbidden - 无法验证您的凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用devise + omniauth,我可以正确连接到twitter api。
I'm using devise + omniauth and I can connect to twitter api correctly.
但是当我尝试使用twitter宝石时,控制台中出现以下错误:
But when I try to use twitter gem, I have the following error in console :
Twitter :: Error :: Forbidden - 无法验证您的凭据
"Twitter::Error::Forbidden - Unable to verify your credentials"
我已经安装gem并在config / initializers / twitter.rb中创建一个初始化器
I have installed the gem and created an initializer at config/initializers/twitter.rb
Twitter.configure do |config|
config.consumer_key = PKe41...
config.consumer_secret = qETY.....
end
我正在尝试一个控制器:
And I'm trying into a controller :
def twitter
@twitter_home_timeline = Twitter.home_timeline
end
推荐答案
Ok ,我发现答案...初始化器中的键必须用引号设置:
Ok, I found the answer... Keys in the initializer must be set with quotation marks :
Twitter.configure do |config|
config.consumer_key = 'PKe41...'
config.consumer_secret = 'qETY.....'
end
这篇关于Twitter :: Error :: Forbidden - 无法验证您的凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!