简体   繁体   English

401未经授权使用OmniAuth-Twitter

[英]401 Unauthorized using OmniAuth-Twitter

I am getting a 401 Unauthorized when trying to implement the OmniAuth-Twitter gem into my rails app in Development I have read several posts saying the server times are mismatched. 尝试在Development我的rails应用程序中实现OmniAuth-Twitter gem时,我收到401 Unauthorized OmniAuth-Twitter ,我读过几篇文章说服务器时间不匹配。

The error comes when calling http://localhost:3000/auth/twitter 调用http://localhost:3000/auth/twitter时出现错误

I have a callback url. 我有一个回调网址。 I have the api keys correct. 我的api键正确。 So I assume the timestamp is the issue. 因此,我认为时间戳是问题。

How exactly can I go about comparing twitter's server time to my local machine's time? 我该如何比较Twitter的服务器时间和本地计算机的时间?

How do I go about adjusting my local machine's time? 如何调整本地机器的时间?

I was following this railscasts episode . 我一直在关注这 In it he states to set the keys like: 他在其中指出要设置以下键:

Rails.application.config.middleware.use OmniAuth::Builder do
   provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
end

But the gem documentations states: 但是gem文档指出:

Rails.application.config.middleware.use OmniAuth::Builder do
   provider :twitter, "CONSUMER_KEY", "CONSUMER_SECRET"
end

Removing the ENV[] solved the issue. 删除ENV[]解决了此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM