Omniauth-twitter返回401

时间:2013-03-30 18:27:59

标签: oauth ruby-on-rails-3.2 omniauth

阶段

我有一个Rails应用程序,它应该使用他们的Twitter帐户验证用户,所以我使用Omniauth-Twitter gem。

我已在dev.twitter.com中配置了一个应用,启用了Sign in with twitter标记,并获得了consumer_keyconsumer_secret

我正在关注本指南https://github.com/arunagw/omniauth-twitter#readme

在Rails应用程序中,我配置了一些文件:

  • config/initializers/omniauth.rb

    Rails.application.config.middleware.use OmniAuth::Builder do
      # Twitter consumer data
      CONSUMER_KEY='xxxxxxxxxxxxxxxxx'
      CONSUMER_SECRET='yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
      provider :twitter, CONSUMER_KEY, CONSUMER_SECRET
    end
    
  • sessions_controller.rb看起来像:

    class SessionsController < ApplicationController
      def create
        raise request.env["omniauth.auth"].to_yaml
      end
    end
    
  • applications.html.erb布局:

    <div id="user_nav">
      <%= link_to "Sign in with Twitter", "/auth/twitter" %>
    </div>
    

    所以除了当我在Sign in with Twitter链接上进行clic时,我提出了一个异常,显示我的身份验证数据或请求我进行Twitter自动化。

问题

而不是这个,它返回这个:

OAuth::Unauthorized (401 Unauthorized):
oauth (0.4.7) lib/oauth/consumer.rb:216:in `token_request'
oauth (0.4.7) lib/oauth/consumer.rb:136:in `get_request_token'
omniauth-oauth (1.0.1) lib/omniauth/strategies/oauth.rb:29:in `request_phase'
omniauth-twitter (0.0.15) lib/omniauth/strategies/twitter.rb:63:in `request_phase'
omniauth (1.1.3) lib/omniauth/strategy.rb:207:in `request_call'
omniauth (1.1.3) lib/omniauth/strategy.rb:174:in `call!'
omniauth (1.1.3) lib/omniauth/strategy.rb:157:in `call'
omniauth (1.1.3) lib/omniauth/builder.rb:48:in `call'

这里有什么问题?

0 个答案:

没有答案