Devise,Omniauth和Twitter [英] Devise, Omniauth and Twitter
问题描述
在我的config / initializers / devise.rb文件中我添加了:
config.omniauth:twitter,consumer_key,consumer_secret
除了上面的Omniauth概述页面中列出的其余代码。
我还添加了一个twitter方法我的OmniauthCallbacksController,但它从来没有被调用由于401。
任何帮助将不胜感激。
尝试在dev.twitter.com上的应用程序设置中填写回调URL。应该是这样的:
回调URL http://yousite.com / auth / twitter / callback
I'm working on a Rails 3 app that uses devise and omniauth and followed the examples given in https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview and it worked well for Facebook accounts, but when I tried adding Twitter auth, I get a '401 Unauthorized' response. To track the problem down I switched the URL for api.twitter.com to http and dumped the network traffic and it looks like it's POSTing to /oauth/access_token twice. The first time I get a 200 response, the second gives the 401. In between it successfully gets user info for the authenticated user using 'GET /1/account/verify_credentials.json' method. I don't understand why the code calls the access_token method the second time.
In my config/initializers/devise.rb file I added:
config.omniauth :twitter, "consumer_key", "consumer_secret"
in addition to the rest of the code outlined in the Omniauth overview page above.
I also added a 'twitter' method in my OmniauthCallbacksController, but it never gets called due to the 401.
Any help would be much appreciated.
Try with filling Callback URL in settings of your application on dev.twitter.com. Should be something like that:
Callback URL http://yousite.com/auth/twitter/callback
这篇关于Devise,Omniauth和Twitter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!