3

omniauth-steam gemを使用してSteamからユーザーを接続し、ユーザーのID64を取得しようとしています。私はRuby on Rails 5.0.1をローカルネットワーク上のApacheを使用してPassengerでサーバーを使用して実行しています。/auth/steamに接続しようとすると、「Connect」ボタン(私はすでにログインしています)でSteam Webページにリダイレクトされます。ボタンをクリックすると、 "invalid_credentials"というメッセージが表示されたエラーページが表示されます。私はSteamにログインしていて問題なくサイトを閲覧できます。そのメッセージはどこから来ていますか?これをどうすれば解決できますか?ここまでは私のコードです。SteamのOpenIdとSteamで接続するOmniAuth gemが "invalid_credentials"エラーを返します

Omniauth初期化子

# config/initializers/omniauth.rb 
Rails.application.config.middleware.use OmniAuth::Builder do 
    provider :steam, Rails.application.secrets.steam_web_api_key 
end 

コントローラー

skip_before_filter :verify_authenticity_token, :only => :auth_callback 

def index 
end 

def auth_callback 
    auth = request.env['omniauth.auth'] 
    session[:current_user] = { 
     :nickname => auth.info['nickname'], 
     :image => auth.info['image'], 
     :uid => auth.uid 
    } 
    redirect_to root_url 
end 

ビュー

<p><%= link_to image_tag("http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_noborder.png"), '/auth/steam' %></p> 

のルート

get 'admin/index' 
post 'auth/steam/callback' => 'admin#auth_callback' 

root 'admin#index' 

エラースタック

invalid_credentials 

Extracted source (around line #25): 
23 def raise_out! 
24  fail(env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type'])) 
25 
26 end 
27 
28 def redirect_to_failure 

omniauth (1.3.1) lib/omniauth/failure_endpoint.rb:25:in `raise_out!' 
omniauth (1.3.1) lib/omniauth/failure_endpoint.rb:20:in `call' 
omniauth (1.3.1) lib/omniauth/failure_endpoint.rb:12:in `call' 
omniauth (1.3.1) lib/omniauth/strategy.rb:479:in `fail!' 
omniauth-openid (1.0.1) lib/omniauth/strategies/open_id.rb:80:in `callback_phase' 
omniauth (1.3.1) lib/omniauth/strategy.rb:227:in `callback_call' 
omniauth (1.3.1) lib/omniauth/strategy.rb:184:in `call!' 
omniauth (1.3.1) lib/omniauth/strategy.rb:164:in `call' 
omniauth (1.3.1) lib/omniauth/builder.rb:63:in `call' 
rack (2.0.1) lib/rack/etag.rb:25:in `call' 
rack (2.0.1) lib/rack/conditional_get.rb:25:in `call' 
rack (2.0.1) lib/rack/head.rb:12:in `call' 
rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context' 
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call' 
activerecord (5.0.1) lib/active_record/migration.rb:553:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call' 
activesupport (5.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__' 
activesupport (5.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks' 
activesupport (5.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks' 
actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call' 
web-console (3.4.0) lib/web_console/middleware.rb:135:in `call_app' 
web-console (3.4.0) lib/web_console/middleware.rb:20:in `block in call' 
web-console (3.4.0) lib/web_console/middleware.rb:18:in `catch' 
web-console (3.4.0) lib/web_console/middleware.rb:18:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call' 
railties (5.0.1) lib/rails/rack/logger.rb:36:in `call_app' 
railties (5.0.1) lib/rails/rack/logger.rb:24:in `block in call' 
activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `block in tagged' 
activesupport (5.0.1) lib/active_support/tagged_logging.rb:26:in `tagged' 
activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `tagged' 
railties (5.0.1) lib/rails/rack/logger.rb:24:in `call' 
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call' 
rack (2.0.1) lib/rack/method_override.rb:22:in `call' 
rack (2.0.1) lib/rack/runtime.rb:22:in `call' 
activesupport (5.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call' 
actionpack (5.0.1) lib/action_dispatch/middleware/static.rb:136:in `call' 
rack (2.0.1) lib/rack/sendfile.rb:111:in `call' 
railties (5.0.1) lib/rails/engine.rb:522:in `call' 
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request' 
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request' 
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop' 
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads' 
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception' 

答えて

0

それは、この場合には、それが原因でスクリプトとスチームのサーバーを実行しているサーバー間の時間差であったことが判明します。私のサーバー上の日付/時刻は数分遅れていました。時刻の差異を修正すると、エラーメッセージが消えてログインプロセスが成功しました。

関連する問題