Twitter“无法验证你的身份”错误 [英] Twitter "could not authenticate you" error

查看:4807
本文介绍了Twitter“无法验证你的身份”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Rails应用程序使用twitter gem,这样我可以将我的博客帖子自动更新到我的twitter feed中。

我遵循 gem自述说明,投掷这在config / initializers / twitter.rb文件中

  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
结束

将这些变量更新到Heroku上,在我的Twitter账户下注册我的应用程序,给账户读取,写入和直接访问,然后尝试通过heroku控制台更新,如下所示:

  Twitter.update(测试Twitter集成)



不幸的是,我得到这个错误:

  Twitter :: Error :: Unauthorized:无法验证您

(后面跟着这些可能无益的细节):/app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/中的

  twitter / response / raise_error.rb:21:在`on_complete'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/response.rb:9:在`块中l'
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:在`call'
from /app/vendor/bundle/ruby/1.9.1/ gems / faraday-0.8.6 / lib / faraday / request / url_encoded.rb:14:`call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/ lib / faraday / request / multipart.rb:13:在`call'
/app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/request/multipart_with_file。 rb:14:在`call'
/app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/connection.rb:247:in`run_request'$ b $ 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:'request'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter- 4.5.0 / lib / twitter / client.rb:70:在`post'
from / app / v endor / bundle / ruby​​ / 1.9.1 / gems / twitter-4.5.0 / lib / twitter / api / utils.rb:82:来自/app/vendor/bundle/ruby/1.9的`object_from_response'
。 1 / gems / twitter-4.5.0 / lib / twitter / api / tweets.rb:129:在`update'
/app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5。 0 / lib / twitter.rb:52:在method_missing'
from(irb):2
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/ lib / rails / commands / console.rb:47:在`start'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console。 rb:8:在`开始'
从/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in`< top(必须)>'脚本/导轨中的
:6中的'require'
来自script / rails:6:'< main>'irb(main):003:0>

Twitter的确至少部分地验证了我,因为之前,当我没有切换到读/写,它曾抱怨过:

  Twitter :: Error :: Unauthorized:处理您的OAuth请求时出错:只读应用程序无法POST 

(为了解决这个问题,我编辑了我的设置并重置了我的OAuth密钥)。



我已经搜索了一下,但在同一情况下我找不到其他人。想知道我是否做错了什么,或者我是否需要等一下。



任何想法? 您提供了一个回调网址吗?

我发现了twitter的新更新,甚至没有使用应用程序配置中的回调url,直到我更新它之前,我遇到了同样的问题,我结束了加入



http: //www.my-website.com/auth/twitter/callback



我甚至没有使用localhost开发,但它开始工作否则,请使用您的代码/宝石进行Twitter身份验证以及您在Twitter上的设置,以便我们可以查看代码并让其进行更新。 你知道是否有什么worng

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?

解决方案

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

这篇关于Twitter“无法验证你的身份”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆