首页 > 解决方案 > 在 Rails 上使用 Omniauth-steam 返回“提供的位置为零。无法构建 URI”

问题描述

我正在尝试使用https://github.com/reu/omniauth-steam但它给了我一个错误

'Nil location provided. Can't build URI'

我尝试按照https://grschafer.com/guides/2013/09/07/steam-openid-and-webapi-with-rails/中的教程进行操作,但我不确定它是否仍然是最新的。

我试着把

skip_before_action :verify_authenticity_token, :only => :auth_callback

从上面的链接或:

protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format == 'application/json' }

正如 2017 年 github 中的相关问题中所述,但它仍然无法正常工作

我的观点是这样的:

<% if session.key? :current_user %>
 <h3>Current user:</h3>
 <%= image_tag session[:current_user][:image] %>
 <p><%= session[:current_user][:nickname] %></p>
 <p><%= session[:current_user][:uid] %></p>
 <% end %>

在会话转储中仍然有我需要的信息:

_csrf_token: "xxxxxxxxxxxxx"
current_user: {"nickname"=>"xxxxx", "image"=>"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/be/xxxxxxxxxxx_medium.jpg", "uid"=>"xxxxxxxx"}

标签: ruby-on-railsrubyoauthomniauthsteam-web-api

解决方案


推荐阅读